Apache NetBeans on Gentoo

NetBeans users on Gentoo might have noticed that dev-util/netbeans was removed from the main tree recently. The reason was that it was pretty outdated and I do not have time to bump it to the newest version using the Gentoo standards. Anyway, there is still a solution. You can find the ebuild for the latest NetBeans in my overlay, named dev-util/netbeans-standalone to not conflict with the previous, now outdated ebuild. Also, up to the standard NetBeans releases, you can find there live ebuild for the latest greatest NetBeans. For those not used to use overlays, see Layman.

Tags: , ,

Development Version of Netbeans in Gentoo

Today I just found some time to ask for Gentoo overlay to put there my latest ebuilds for development version of Netbeans, that is for nightly builds of Netbeans 7.0. You can find the overlay at http://git.overlays.gentoo.org/gitweb/?p=dev/fordfrog.git. If you do not know how to use Gentoo overlays, you can find needed information in Overlay guide.

It is safe to give Netbeans 7.0 development a try on Gentoo as Netbeans 7.0 installs in separate slot so you can have in your system both Netbeans 7.0 and 6.9.1 and even older versions. Up to that, though it is still development version, it is pretty stable and I use it myself for my work for several weeks (maybe even months, my poor memory) already.

You might also notice that I have split the single ebuild into several ebuilds, one ebuild for each Netbeans cluster plus one for Netbeans JavaDoc. I decided to do so for several reasons.

First, for me, it’s much easier to manage Netbeans ebuilds when I can rebuild just single cluster instead of whole Netbeans on each change in ebuilds etc. I can also emerge several clusters in parallel using emerge --jobs switch. That saves some time and does not load my laptop much anyway as javac does not utilize parallel compilation.

Second, for users adding/removing clusters to/from current installation does not require complete rebuild of Netbeans anymore but you emerge or unmerge just the cluster(s) that you want, so you save some time on this. Also, the same as above applies, you can emerge several clusters in parallel and save some time.

And third, there are some applications that are built on top of Netbeans Platform, like VisualVM, so these can easily reuse dev-java/netbeans-platform package without need to pull in whole Netbeans with its huge list of dependencies.

This set of ebuilds supports applying custom patches to the Netbeans sources as the previous ebuild does. You just have to set up NETBEANS70_PATCHES_DIR variable so that it points to directory where you have the patches that you want to apply. I have this line in /etc/make.conf:


If you like to tweak Netbeans to your needs, you might also want to read my article on .

Tags: ,

NetBeans, Maven and Code Coverage

I just came across Maven Test Coverage plugin for Netbeans. It is available for Netbeans 7.0 builds. It is really useful when you write tests for your code and want to make sure your tests cover all important execution paths.

The plugin runs for you Cobertura test coverage goals and displays coverage report for the tests. It also provides higlights of code lines according to your tests code coverage.

You can find more information (installation, how to use it, …) about the plugin at MavenCodeCoverage website.

Tags: , ,

Modifying NetBeans Generated Getters And Setters

For quite a long time I was thinking about automatically adding Javadoc to getters and setters generated by NetBeans, and also automatically adding final modifier to setter parameter. NetBeans does not have this feature yet. So what exactly I wanted?

package com.mycompany.mavenproject1;

public class App {

     * Contains exciting values.
    private String test;

     * Getter for {@link #test}.
     * @return {@link #test}
    public String getTest() {
        return test;

     * Setter for {@link #test}.
     * @param test {@link #test}
    public void setTest(final String test) {
        this.test = test;

With some guidance from Petr Pišl from NetBeans team, I was able to do this patch: netbeans-getter-setter.patch. You can patch your NetBeans with it, adjust the generated Javadocs to your needs, compile NetBeans and your generated getters and setters should contain exactly what you need without pressing any extra key on your keyboard.

If you want to achieve the same for php, look at org.netbeans.modules.php.editor.codegen.CGSGenerator at GETTER_TEMPLATE and SETTER_TEMPLATE declarations. it’s even easier to modify these to get the comments added.

Sure it would be better if this would be done using templates, but atm this is better than nothing.

Also I updated NetBeans ebuild in Gentoo so that you can emerge NetBeans including your patches. You can find more info at NetBeans article at Gentoo Wiki.


NetBeans And ssh-agent

I am using SSH and DSA key for access to my company repositories. But NetBeans always failed to connect to the server because it did not find app which it could use to ask me for password. After I installed x11-ssh-askpass, the situation improved in a way that NetBeans asked me for my DSA key password each time I issued some command that communicates with the repo. As I use keychain, other way that makes the things work flawlessly is running NetBeans from terminal window, but it has one drawback – it’s pretty annoying to run NetBeans from terminal.

Finally I found a way to make it all work in (for me) ideal way. I modified NetBeans script so that it:

  • runs keychain
  • sources keychain file that exports all needed variables
  • adds keys that I want to the ssh-agent and prompts me for keys password if ssh-agent does not handle the keys yet

Here is the patch for NetBeans script:

--- /usr/share/netbeans-6.9/bin/netbeans.orig	2010-07-17 04:35:11.777217529 +0200
+++ /usr/share/netbeans-6.9/bin/netbeans	2010-07-17 05:25:38.895871679 +0200
@@ -169,6 +169,19 @@
+    keychain -q
+    if [ -e "$HOME/.keychain/$HOSTNAME-sh" ]; then
+        . $HOME/.keychain/$HOSTNAME-sh
+    fi
+    if [ -e $userdir/keychain-keys.txt ]; then
+        for key in `cat $userdir/keychain-keys.txt`; do
+            SSH_ASKPASS=`which x11-ssh-askpass`
+            export SSH_ASKPASS
+            if [ -n "$key" ]; then
+                keychain $key
+            fi
+	done
+    fi
     if [ "${founduserdir}" = "yes" ]; then
         exec $sh "$nbexec" "$@"

So if you have password protected SSH keys, all that you need to do to make them work in NetBeans without being annoyed is:

  • install keychain and x11-ssh-askpass
  • apply the patch above to NetBeans executable script
  • if you want to be prompted for SSH key passwords on NetBeans startup, create file $userdir/keychain-keys.txt and put there name of the files with the keys

Just minor update, I added this support to Gentoo ebuild for NetBeans, so since netbeans-6.9-r3 this feature can be activated by enabling ‘keychain’ use flag.

Tags: ,

NetBeans And System Tomcat

At this moment, NetBeans and Tomcat does not work together with each other in Gentoo out of the box. You need to do minor tweak to make it work, but it’s really easy:

# adds user to tomcat group
gpasswd -a user tomcat
# NetBeans expects conf directory in Catalina home
ln -s /etc/tomcat-6/ /usr/share/tomcat-6/conf
# if you want NetBeans to create manager account, you need this
chmod g+w /etc/tomcat-6/tomcat-users.xml

You might need to relogin/restart after gpasswd to get the new user group applied to your user in your desktop environment.

Tags: , ,

NetBeans, IcedTea And Fonts

I bought new laptop and while installing Gentoo on it, I decided to try IcedTea instead of Sun-JDK. But when running NetBeans using IcedTea, the fonts were of serif type which on my resolution was not much readable. Anyway, the solution is easy. Just create symlink to fontconfig.properties in the IcedTea installation:

cd /opt/icedtea6-bin-1.8.0/jre/lib/
ln -s fontconfig.Fedora.properties.src fontconfig.properties

When you start NetBeans after this change, the used font will be of sans serif type which is much more readable. More info about this issue can be found at Gentoo Bugzilla.

Tags: ,