5

I installed Netbeans 11.2 on Ubuntu 18.04 via snap.

Now i want to configure Netbeans, modifying netbeans.conf. This file is placed at /snap/netbeans/current/netbeans/etc/ and is mounted as read-only file system. So i assume you should not edit this file here.

How do i configure Netbeans if the classic way (editing netbeans.conf) is blocked?

Note: I want to set netbeans_jdkhome="~/.sdkman/candidates/java/latest/".

UPDATE

This works:

netbeans --jdkhome ~/.sdkman/candidates/java/latest
rmuller
  • 12,062
  • 4
  • 64
  • 92
  • I tried the above command but I am getting the error: $ netbeans --jdkhome ~/.sdkman/candidates/java/latest Cannot find java. Please use the --jdkhome switch. – user2994783 Mar 06 '21 at 23:47

2 Answers2

9

You CAN have user local versions of the netbeans configuration. Just copy the global netbeans.conf from the global snap location to your Netbeans user directory and make your changes there.

Example for version 11.3 of Netbeans:

mkdir -p ~/snap/netbeans/common/data/11.3/etc
cp /snap/netbeans/current/netbeans/etc/netbeans.conf ~/snap/netbeans/common/data/11.3/etc/netbeans.conf
gedit ~/snap/netbeans/common/data/11.3/etc/netbeans.conf

NOTE: You will need to repeat this process whenever the user directory changes as a result of a version update. Ie. from 11.3 -> 12, etc.

This worked till 12.4. Newer versions of the Snap package has changed the location of the NetBeans userdir so the script above would look like:

mkdir -p ~/snap/netbeans/current/etc
cp /snap/netbeans/current/netbeans/etc/netbeans.conf ~/snap/netbeans/current/etc/netbeans.conf
gedit ~/snap/netbeans/current/etc/netbeans.conf

NOTE: You will not need to repeat this process on version updates.

Kim Jersin
  • 106
  • 1
  • 2
2

There is no direct solution to your problem using snap. See "Why can snap files not be modified in any way?":

It's impossible to change the contents of the snap without re-building the snap. This is primarily a security measure, to ensure that the snap hasn't been tampered with.

However, there is a workaround: pass the path of the JDK to be used using the --jdkhome parameter when starting NetBeans. For example, to start NetBeans 11.2 using JDK 8 on Windows on my PC:

C:\NetBeans112\bin\netbeans.exe --jdkhome C:\Java\jdk1.8.0_221

consoleStartUp

See Can I specify the JDK to run NetBeans on? for further details.

skomisa
  • 16,436
  • 7
  • 61
  • 102