Skip to content

Instantly share code, notes, and snippets.

@moschlar
Last active August 29, 2015 14:09
Show Gist options
  • Save moschlar/45d38d555184e4d3a69f to your computer and use it in GitHub Desktop.
Save moschlar/45d38d555184e4d3a69f to your computer and use it in GitHub Desktop.
NetBeans on Gentoo Linux

The Netbeans Launcher works not so well with Gentoo Linux' Java environment.

I did install Netbeans trough the Installer and OpenJDK via the package dev-java/icedtea-bin, which installs to e.g. /opt/icedtea-bin-7.2.5.3/.

Now the Netbeans Installer would hardcode netbeans_jdkhome="/opt/icedtea-bin-7.2.5.3" in the ~/.local/opt/netbeans-8.0.1/etc/netbeans.conf file. Of course, this path breaks on the next (minor) update of dev-java/icedtea-bin.

Simply commenting out the netbeans_jdkhome line does not work due to the way Gentoo uses its eselect mechanism for selecting a system/user Java VM implementation from a variety of installed ones. nbexecs autodetecting of the java executable fails because of the run-java-tool.bash script to which /usr/bin/java gets symlinked. I hope the symlinkery gets clear from the shell session below, if not, I'd be happy to supply more information.

For the curious, setting netbeans_jdkhome="/etc/java-config-2/current-system-vm" manually makes nbexec skip the autodetection and just use the java that it finds there.

I think the best way on a Gentoo system would be to skip autodetection completely and just use what is java in the path (e.g. at /usr/bin/java and to trust the selected application from eselect.

$ echo $JAVA_HOME
/etc/java-config-2/current-system-vm
$ ls -l $JAVA_HOME
lrwxrwxrwx 1 root root 27 7. Mai 2014 /etc/java-config-2/current-system-vm -> //usr/lib/jvm/icedtea-bin-7
$ ls -l /etc/java-config-2/current-system-vm
lrwxrwxrwx 1 root root 27 7. Mai 2014 /etc/java-config-2/current-system-vm -> //usr/lib/jvm/icedtea-bin-7
$ ls -l //usr/lib/jvm/icedtea-bin-7
lrwxrwxrwx 1 root root 24 18. Nov 00:15 //usr/lib/jvm/icedtea-bin-7 -> /opt/icedtea-bin-7.2.5.3
$ ls -l /opt/icedtea-bin-7.2.5.3
total 0
drwxr-xr-x 1 root root 570 18. Nov 00:15 bin
drwxr-xr-x 1 root root 140 18. Nov 00:15 include
drwxr-xr-x 1 root root 122 18. Nov 00:15 jre
drwxr-xr-x 1 root root 120 18. Nov 00:15 lib
drwxr-xr-x 1 root root 34 18. Nov 00:15 man
$ bash -x /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
+ PRG=/home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
++ resolve_symlink /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
++ file=/home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
++ '[' -h /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec ']'
++ echo /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
+ PRG=/home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
++ dirname /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/nbexec
+ progdir=/home/moschlar/.local/opt/netbeans-8.0.1/platform/lib
++ absolutize_path /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/..
+++ pwd
++ oldpwd=/home/moschlar
++ cd /home/moschlar/.local/opt/netbeans-8.0.1/platform/lib/..
+++ pwd
++ abspath=/home/moschlar/.local/opt/netbeans-8.0.1/platform
++ cd /home/moschlar
++ echo /home/moschlar/.local/opt/netbeans-8.0.1/platform
+ plathome=/home/moschlar/.local/opt/netbeans-8.0.1/platform
+ jargs=
+ jargs=' -Dnetbeans.home="/home/moschlar/.local/opt/netbeans-8.0.1/platform"'
+ args=
+ launcher_args=
+ prefixcp=
+ postfixcp=
+ updater_class=org.netbeans.updater.UpdaterFrame
+ parse_args
+ '[' 0 -gt 0 ']'
+ '[' -z '' ']'
+ case "`uname`" in
++ uname
++ which javac
+ javac=/usr/bin/javac
+ '[' -z /usr/bin/javac ']'
++ resolve_symlink /usr/bin/javac
++ file=/usr/bin/javac
++ '[' -h /usr/bin/javac ']'
+++ ls -ld /usr/bin/javac
++ ls='lrwxrwxrwx 1 root root 44 7. Mai 2014 /usr/bin/javac -> /usr/libexec/eselect-java/run-java-tool.bash'
+++ expr 'lrwxrwxrwx 1 root root 44 7. Mai 2014 /usr/bin/javac -> /usr/libexec/eselect-java/run-java-tool.bash' : '^.*-> \(.*\)$'
++ link=/usr/libexec/eselect-java/run-java-tool.bash
++ expr /usr/libexec/eselect-java/run-java-tool.bash : '^/'
++ file=/usr/libexec/eselect-java/run-java-tool.bash
++ '[' -h /usr/libexec/eselect-java/run-java-tool.bash ']'
++ echo /usr/libexec/eselect-java/run-java-tool.bash
+ javac=/usr/libexec/eselect-java/run-java-tool.bash
++ dirname /usr/libexec/eselect-java/run-java-tool.bash
+ jdkhome=/usr/libexec/eselect-java/..
+ '[' '!' -x /usr/libexec/eselect-java/../bin/java ']'
+ echo 'Cannot find java. Please use the --jdkhome switch.'
Cannot find java. Please use the --jdkhome switch.
+ exit 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment