简体   繁体   中英

How to configure netbeans when installed as snap package?

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

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.

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

控制台启动

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM