Search code examples
javaubuntunetbeansnetbeans-11

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

Solution

  • 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.