Netbeans

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
:
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
Install
the
netbeans
package.
Tips and tricks
Preserving configuration changes
Note
The global
/usr/etc/netbeans.conf
will be overwritten during updates. To keep changes, add them to your local
~/.netbeans/
version
/etc/netbeans.conf
(you will need to create the
etc
directory 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.
Another alternative is to use a
pacman hook
that modifies the system-wide configuration file. For example:
/etc/pacman.d/hooks/10-netbeans.hook
[Trigger]
Type = Path
Operation = Install
Operation = Upgrade
Target = usr/etc/netbeans.conf

[Action]
Description = Updating netbeans.conf
When = PostTransaction
Exec = /usr/bin/sed -i -E 's/netbeans_default_options="(.*)"/netbeans_default_options="\1 -J-Dawt.useSystemAAFontSettings=on -J-Dswing.aatext=true --fontsize 15"/g' /usr/etc/netbeans.conf
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 can thus happen at two levels:
Java
.
In the Netbeans configuration. If the file is missing, you may need to create it.
~/.netbeans/
version
/etc/netbeans.conf
[...]
netbeans_default_options="
[...]
-J-Dswing.aatext=TRUE -J-Dawt.useSystemAAFontSettings=on"
[...]
Look and feel
To change Netbeans's 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 extensions 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.
First install your desired version of Tomcat (see
Tomcat
).
While you can modify the configuration files in
/etc/tomcat
n
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
~/.tomcat
n
and create that directory.
Copy
/etc/tomcat
n
/
to
~/.tomcat
n
/conf
, e.g.
cp -r /etc/tomcat
n
~/.tomcat
n
/conf
and
chown -R $(id -un):$(id -gn) ~/.tomcat
n
, both with root privileges
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:
~/.tomcat
n
/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 ~/.tomcat
n
/webapps
and
ln -s /var/lib/tomcat
n
/webapps/manager ~/.tomcat
n
/webapps/manager
Provide a
temp
directory:
mkdir ~/.tomcat
n
/temp
If needed, change the port at which Tomcat runs by editing
~/.tomcat
n
/conf/server.xml
.
Have Tomcat write its logs somewhere else than
/var/log/tomcat
n
Unfortunately, Netbeans refuses to continue unless it can read
/etc/tomcat
n
/server.xml
, so temporarily give the file
644
permissions
. Change the permissions back later.
Then, in Netbeans:
Go to
Tools > Servers > Add Server
and select
Apache Tomcat
. Click
Next
.
In
Server location
, specify
/usr/share/tomcat
n
.
Check
Use Private Configuration Folder (Catalina Base)
and specify the full path to directory
~/.tomcat
n
. 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
~/.tomcat
n
/logs
, not
/var/log/tomcat
n
.
Integrate Netbeans with GNOME-Keyring
Install
libgnome-keyring
AUR
.
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 information 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"
[...]
Wrong Directory for JDK/JRE
It might be that after installation,
netbeans_jdkhome
is set incorrectly:
/usr/share/netbeans/etc/netbeans.conf
[...]
netbeans_jdkhome="/home/aur/aur-netbeans-cpp/pkg/netbeans-cpp/usr/share/netbeans/bin/jre" (example)
[...]
Just comment out this line;
netbeans
will find the proper path on startup. Since
netbeans.conf
might be overwritten during an update, this procedure might need to be done again after an update, or you put
netbeans_jdkhome
into the configuration file in your home directory (see above).
Plugin installation fails due to lack of unpack200
The unpack200 plugin was removed in
JDK
version 14, causing plugin installation in Netbeans to fail. As a workaround, one can set
netbeans_jdkhome
in
/usr/share/netbeans/etc/netbeans.conf
to an earlier JDK version. After plugin installation, you can return to the default JDK, but this will have to be repeated for each plugin update.