8

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 
1
  • 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. Commented Mar 6, 2021 at 23:47

2 Answers 2

13

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.