Difference between revisions of "Netbeans"

From ArchWiki
Jump to: navigation, search
(Remove obsolete part.)
m (Font antialiasing in Netbeans: missing '"')
 
(31 intermediate revisions by 17 users not shown)
Line 2: Line 2:
 
[[ar:Netbeans]]
 
[[ar:Netbeans]]
 
[[es:Netbeans]]
 
[[es:Netbeans]]
 +
[[ja:Netbeans]]
 
'''Netbeans''' is an integrated development environment (IDE) for developing with Java, JavaScript, PHP, Python, Ruby, Groovy, C, C++, Scala, Clojure, and other languages.
 
'''Netbeans''' is an integrated development environment (IDE) for developing with Java, JavaScript, PHP, Python, Ruby, Groovy, C, C++, Scala, Clojure, and other languages.
  
 
From [[Wikipedia:Netbeans|Wikipedia article]]:
 
From [[Wikipedia:Netbeans|Wikipedia article]]:
 
:"''The NetBeans IDE is written in Java and can run anywhere a compatible JVM is installed, including Windows, Mac OS, Linux, and Solaris. A JDK is required for Java development functionality, but is not required for development in other programming languages.''"
 
:"''The NetBeans IDE is written in Java and can run anywhere a compatible JVM is installed, including Windows, Mac OS, Linux, and Solaris. A JDK is required for Java development functionality, but is not required for development in other programming languages.''"
 +
 +
== Installation ==
 +
 +
As you can see on the [https://netbeans.org/downloads/index.html download page] , Netbeans is actually segmented into different flavors, each made for a specific use case. There is also a version gathering all the different flavors together.
 +
 +
If you want to install all the flavors at once, [[install]] the {{Pkg|netbeans}} package or {{aur|netbeans-nightly}}.
 +
 +
If you want a specific flavor, in order to have a minimal installation for example, install one of the following packages:
 +
 +
* Java SE: {{aur|netbeans-javase}} or {{aur|netbeans-javase-nightly}};
 +
* Java EE: {{aur|netbeans-javaee}} or {{aur|netbeans-javaee-nightly}};
 +
* HTML5/Javascript or PHP: {{aur|netbeans-php}} or {{aur|netbeans-php-nightly}};
 +
:The versions provider either for the flavor HTML5/Javascript or the flavor PHP are actually the same package.
 +
* C/C++: {{aur|netbeans-cpp}} or {{aur|netbeans-cpp-nightly}}.
 +
 +
Please note the {{ic|-nightly}} versions are actually binaries versions compiled everyday from the trunk branch from the development repository.
  
 
== Tips and tricks ==
 
== Tips and tricks ==
{{Note|The global netbeans.conf {{Ic|/usr/share/netbeans/etc/netbeans.conf}} will be overwritten during updates. To keep changes add them to your local netbeans.conf {{ic|~/.netbeans/<ver>/etc/netbeans.conf}} (you will need to create the etc dir and the .conf file).}}
+
{{Note|The global netbeans.conf {{Ic|/usr/share/netbeans/etc/netbeans.conf}} will be overwritten during updates. To keep changes add them to your local netbeans.conf {{ic|~/.netbeans/''version''/etc/netbeans.conf}} (you will need to create the etc dir and the .conf file).}}
 
*Settings in local version of netbeans.conf override the same settings in the global copy of the file.
 
*Settings in local version of netbeans.conf override the same settings in the global copy of the file.
 
*Command-line options override settings in either of the configuration files.
 
*Command-line options override settings in either of the configuration files.
 +
 
=== Font antialiasing in Netbeans ===
 
=== Font antialiasing in Netbeans ===
==== Netbeans Specifically ====
+
As Netbeans is written in [[Java]], the font rendering is managed by Java itself and also by Netbeans. Modifying the font antialiasing parameters must thus happen at two levels:
Add {{Ic|-J-Dswing.aatext&#61;TRUE -J-Dawt.useSystemAAFontSettings&#61;on}} to the 'netbeans_default_options' line of your netbeans.conf file.
+
* [[Java#Better font rendering|Java]].
 
+
* In the Netbeans configuration
==== Java Generally ====
+
{{hc|~/.netbeans/''version''/etc/netbeans.conf|2=
See [[Java#Better font rendering ]].
+
''[...]''
 +
netbeans_default_options="''[...]''-J-Dswing.aatext=TRUE -J-Dawt.useSystemAAFontSettings=on"
 +
''[...]''}}
  
 
=== Look and feel ===
 
=== Look and feel ===
To change Netbeans look and feel, add switch {{Ic|--laf yourLookAndFeel}} to IDE command line by appending it to ‘netbeans_default_options’ section of {{Ic|/usr/share/netbeans/etc/netbeans.conf}} or editing ''.desktop'' file with which you launch Netbeans.
+
To change Netbeans look and feel, go to ''Tools > Options > Appearance > Look and Feel''
  
For GTK:
+
To add a dark look and feel to the GUI but also to the colorschemes used in the code, you can install one of the following certified extension from the plugin directory which can be reached from ''Tools > Plugins > Available Plugins'':
{{Ic|--laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel}}
+
* ''Dark Look And Feel Themes''
 +
* ''Darcula LAF for NetBeans'': which, as of January 2017, better integrates with current [[Desktop environment|desktop environments]] and mimic the default Darcula look and feel from used in IntelliJ IDEA or [[Android#Android Studio|Android Studio]].
  
For Nimbus:
+
=== Integrate with the Apache Tomcat Servlet Container ===
{{Ic|--laf com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel}}
 
  
== Troubleshooting ==
+
It is possible to debug web applications running on [[Tomcat]] from within Netbeans, using stock Arch packages for both Netbeans and Tomcat. While this section is written for {{ic|tomcat7}}, this applies to all versions of Tomcat currently in the repositories. (To check which are available, run {{ic|pacman -Ss tomcat}})
=== OpenJDK vs Sun's JDK ===
 
Netbeans 7.0-1 will not ALWAYS work with OpenJDK. Some reported issues are:
 
* Starting - In some cases, netbeans will not start.
 
* Installation - The .sh script provided by netbeans will not launch wizard (any proofs?).
 
* JavaFX module does not work (see {{Bug|29843}}).
 
  
=== Glassfish server - Can`t download Glassfish server I/O Exception ===
+
* First install your desired version of Tomcat, such as {{ic|pacman -S tomcat7}} (see also [[Tomcat]]).
If you are trying add new Glassfish server, you can`t download the server. Netbeans returns
+
* While you can modify the configuration files in {{ic|/etc/tomcat7}} to work with Netbeans debugging, it is recommended you create local copies and use those instead. That way, you still can run Tomcat as an ongoing system service, while debuggging with a different instance:
I/O Exception: http://java.net/download/glassgish/3.0.1/release/glassfish-3.0.1-ml.zip
+
** Pick a location for the local configuration files, such as {{ic|~/.tomcat7}} and create that directory.
 +
** Copy {{ic|/etc/tomcat7/}} to {{ic|~/.tomcat7/conf}}, e.g. {{ic|sudo cp -r /etc/tomcat7 ~/.tomcat7/conf}} and {{ic|sudo chown -R $(id -un):$(id -gn) ~/.tomcat7}}
 +
* Clean up the Tomcat users and permission file, so Netbeans can insert what it needs. Edit the tomcat user file without any user and role information in it:
 +
{{hc|~/.tomcat7/conf/tomcat-users.xml|2=
 +
<?xml version='1.0' encoding='utf-8'?>
 +
<tomcat-users xmlns="http://tomcat.apache.org/xml"
 +
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 +
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
 +
              version="1.0">
 +
</tomcat-users>}}
 +
* Make the "manager" app accessible from your local configuration: {{ic|mkdir ~/.tomcat7/webapps}} and {{ic|ln -s /var/lib/tomcat7/webapps/manager ~/.tomcat7/webapps/manager}}
 +
* Provide a temp directory: {{ic|mkdir ~/.tomcat7/temp}}
 +
* If needed, change the port at which Tomcat runs by editing {{ic|~/.tomcat7/conf/server.xml}}
 +
* Have Tomcat write its logs somewhere else than {{ic|/var/log/tomcat7}}
 +
* Unfortunately, Netbeans refuses to continue unless you make file {{ic|/etc/tomcat7/server.xml}} readable to it. So {{ic|sudo chmod 644 /etc/tomcat7/server.xml}} temporarily, and change it back later.
  
Solution is:
+
Then, in Netbeans:
* Download GlassFish Server Open Source Edition manualy from official site, actual link is http://download.java.net/glassfish/3.0.1/release/glassfish-3.0.1-ml.zip
+
* Go to ''Tools > Servers > Add Server'' and select ''Apache Tomcat''. Click ''Next''.
* Extract from zip to any location
+
* In ''Server location'', specify {{ic|/usr/share/tomcat7}}
 +
* Check ''Use Private Configuration Folder (Catalina Base)'' and specify the full path to directory {{ic|~/.tomcat7}}. This must be the full path, as Netbeans does not recognize the meaning of {{ic|~}}.
 +
* Finally, pick a username and password. Check ''Create user if it does not exist''. This will configure Netbeans, but also add the user information to the {{ic|tomcat-users.xml}} file.
  
=== Netbeans doesn't start after its first start ===
+
Note that this local instance of Tomcat will write its logs to {{ic|~/.tomcat7/logs}}, not {{ic|/var/log/tomcat7}}.
If you receive a message like this when executing from terminal:
 
{{hc|# netbeans -h|
 
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/java-6-openjdk/jre/lib/i386/libsplashscreen.so: libgif.so.4: cannot open shared object file: No such file or directory
 
}}
 
  
You have two options:
+
=== Integrate Netbeans with kwallet ===
* You can start Netbeans using the --nosplash option:
+
Netbeans may need to store some passwords. It can do that in kwallet. See [http://wiki.netbeans.org/FaqMasterPasswordDialog this article] in the Netbeans wiki.
# netbeans --nosplash
 
* Or, install the missing library ({{Pkg|libungif}}), then starting Netbeans as usual will work.
 
  
[https://bbs.archlinux.org/viewtopic.php?id=118930 Arch forum thread]
+
However, you need to install and configure {{AUR|qtchooser}} so that netbeans find the qdbus command:
 +
$ ln -s /etc/xdg/qtchooser/4.conf ~/.config/qtchooser/default.conf
  
=== Netbeans starts with a completely grey window ===
+
See forum discussion [https://bbs.archlinux.org/viewtopic.php?pid=1374434#p1374434]
{{Out of date|most likely fixed in current versions of OpenJDK}}
 
See [[Java#Impersonate Another Window Manager]]
 
  
This may not be quite 100% out of date; the problem occurred while using NetBeans 7.2, OpenJDK 7.u7_2.3.2-2, "$ java -version" reporting 1.7.0_07.  The following is robbed from Awesome's wiki (although I experienced the problem using Xmonad), which fixed my all-grey window problem:
+
== Troubleshooting ==
  
<pre>$ _JAVA_AWT_WM_NONREPARENTING=1; export _JAVA_AWT_WM_NONREPARENTING</pre>
+
=== Maven problems with small tmpfs ===
 +
If your system has a small tmpfs partition you will have problems unpacking the maven index (will continue downloading again after failing to unpack). To fix this issue, append the following pieces of informations in the Netbeans configuration file accordingly.
 +
{{hc|~/.netbeans/''version''/etc/netbeans.conf|2=
 +
''[...]''
 +
netbeans_default_options="''[...]''-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Djava.io.tmpdir=/path/to/tmp/dir"
 +
''[...]''}}

Latest revision as of 06:44, 16 February 2017

Netbeans is an integrated development environment (IDE) for developing with Java, JavaScript, PHP, Python, Ruby, Groovy, C, C++, Scala, Clojure, and other languages.

From Wikipedia article:

"The NetBeans IDE is written in Java and can run anywhere a compatible JVM is installed, including Windows, Mac OS, Linux, and Solaris. A JDK is required for Java development functionality, but is not required for development in other programming languages."

Installation

As you can see on the download page , Netbeans is actually segmented into different flavors, each made for a specific use case. There is also a version gathering all the different flavors together.

If you want to install all the flavors at once, install the netbeans package or netbeans-nightlyAUR.

If you want a specific flavor, in order to have a minimal installation for example, install one of the following packages:

The versions provider either for the flavor HTML5/Javascript or the flavor PHP are actually the same package.

Please note the -nightly versions are actually binaries versions compiled everyday from the trunk branch from the development repository.

Tips and tricks

Note: The global netbeans.conf /usr/share/netbeans/etc/netbeans.conf will be overwritten during updates. To keep changes add them to your local netbeans.conf ~/.netbeans/version/etc/netbeans.conf (you will need to create the etc dir and the .conf file).
  • Settings in local version of netbeans.conf override the same settings in the global copy of the file.
  • Command-line options override settings in either of the configuration files.

Font antialiasing in Netbeans

As Netbeans is written in Java, the font rendering is managed by Java itself and also by Netbeans. Modifying the font antialiasing parameters must thus happen at two levels:

  • Java.
  • In the Netbeans configuration
~/.netbeans/version/etc/netbeans.conf
[...]
netbeans_default_options="[...]-J-Dswing.aatext=TRUE -J-Dawt.useSystemAAFontSettings=on"
[...]

Look and feel

To change Netbeans look and feel, go to Tools > Options > Appearance > Look and Feel

To add a dark look and feel to the GUI but also to the colorschemes used in the code, you can install one of the following certified extension from the plugin directory which can be reached from Tools > Plugins > Available Plugins:

  • Dark Look And Feel Themes
  • Darcula LAF for NetBeans: which, as of January 2017, better integrates with current desktop environments and mimic the default Darcula look and feel from used in IntelliJ IDEA or Android Studio.

Integrate with the Apache Tomcat Servlet Container

It is possible to debug web applications running on Tomcat from within Netbeans, using stock Arch packages for both Netbeans and Tomcat. While this section is written for tomcat7, this applies to all versions of Tomcat currently in the repositories. (To check which are available, run pacman -Ss tomcat)

  • First install your desired version of Tomcat, such as pacman -S tomcat7 (see also Tomcat).
  • While you can modify the configuration files in /etc/tomcat7 to work with Netbeans debugging, it is recommended you create local copies and use those instead. That way, you still can run Tomcat as an ongoing system service, while debuggging with a different instance:
    • Pick a location for the local configuration files, such as ~/.tomcat7 and create that directory.
    • Copy /etc/tomcat7/ to ~/.tomcat7/conf, e.g. sudo cp -r /etc/tomcat7 ~/.tomcat7/conf and sudo chown -R $(id -un):$(id -gn) ~/.tomcat7
  • Clean up the Tomcat users and permission file, so Netbeans can insert what it needs. Edit the tomcat user file without any user and role information in it:
~/.tomcat7/conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
</tomcat-users>
  • Make the "manager" app accessible from your local configuration: mkdir ~/.tomcat7/webapps and ln -s /var/lib/tomcat7/webapps/manager ~/.tomcat7/webapps/manager
  • Provide a temp directory: mkdir ~/.tomcat7/temp
  • If needed, change the port at which Tomcat runs by editing ~/.tomcat7/conf/server.xml
  • Have Tomcat write its logs somewhere else than /var/log/tomcat7
  • Unfortunately, Netbeans refuses to continue unless you make file /etc/tomcat7/server.xml readable to it. So sudo chmod 644 /etc/tomcat7/server.xml temporarily, and change it back later.

Then, in Netbeans:

  • Go to Tools > Servers > Add Server and select Apache Tomcat. Click Next.
  • In Server location, specify /usr/share/tomcat7
  • Check Use Private Configuration Folder (Catalina Base) and specify the full path to directory ~/.tomcat7. This must be the full path, as Netbeans does not recognize the meaning of ~.
  • Finally, pick a username and password. Check Create user if it does not exist. This will configure Netbeans, but also add the user information to the tomcat-users.xml file.

Note that this local instance of Tomcat will write its logs to ~/.tomcat7/logs, not /var/log/tomcat7.

Integrate Netbeans with kwallet

Netbeans may need to store some passwords. It can do that in kwallet. See this article in the Netbeans wiki.

However, you need to install and configure qtchooserAUR so that netbeans find the qdbus command:

$ ln -s /etc/xdg/qtchooser/4.conf ~/.config/qtchooser/default.conf

See forum discussion [1]

Troubleshooting

Maven problems with small tmpfs

If your system has a small tmpfs partition you will have problems unpacking the maven index (will continue downloading again after failing to unpack). To fix this issue, append the following pieces of informations in the Netbeans configuration file accordingly.

~/.netbeans/version/etc/netbeans.conf
[...]
netbeans_default_options="[...]-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Djava.io.tmpdir=/path/to/tmp/dir"
[...]