NetBeans snap - Java configuration

31 Views Asked by At

I've installed the NetBeans snap on Ubuntu 23.10. I've also installed the OpenJDK v22 snap.

When I try to run netbeans in my shell, I get the error:

Cannot find java. Please use the --jdkhome switch.

How can I make NetBeans aware of the openJDK snap?

The OpenJDK snap seems to be installed in the location below because when I type openjdk in my shell, I see the following:

/var/snap/openjdk/1735/openjdk.env

I already tried adding source /var/snap/openjdk/1735/openjdk.env to my .bashrc file to ensure that when I run java -version it knows that I'm using OpenJDK. This doesn't work for NetBeans though.

Related snap packages:

https://snapcraft.io/netbeans

https://snapcraft.io/openjdk

1

There are 1 best solutions below

0
user23524156 On

I was able to get netbeans running by executing the following commands in the shell.

  1. Setting the JAVA_HOME environment variable:
export JAVA_HOME=/snap/openjdk/current/jdk

2.Add Java_HOME to the executable PATH

export PATH=$JAVA_HOME/bin:$PATH

I will add the two commands above to my ~/.bashrc file so that those two commands are executed when starting the shell.

NOTE - This only works for the shell not the Ubuntu UI.

Related documentation:

https://github.com/jgneff/openjdk

https://snapcraft.io/openjdk