简体   繁体   English

安装为 snap package 时如何配置 netbeans?

[英]How to configure netbeans when installed as snap package?

I installed Netbeans 11.2 on Ubuntu 18.04 via snap.我通过 snap 在 Ubuntu 18.04 上安装了 Netbeans 11.2。

Now i want to configure Netbeans, modifying netbeans.conf .现在我想配置 Netbeans,修改netbeans.conf This file is placed at /snap/netbeans/current/netbeans/etc/ and is mounted as read-only file system.该文件位于/snap/netbeans/current/netbeans/etc/并安装为只读文件系统。 So i assume you should not edit this file here.所以我假设你不应该在这里编辑这个文件。

How do i configure Netbeans if the classic way (editing netbeans.conf ) is blocked?如果经典方式(编辑netbeans.conf )被阻止,我该如何配置 Netbeans ?

Note: I want to set netbeans_jdkhome="~/.sdkman/candidates/java/latest/" .注意:我想设置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.您可以拥有 netbeans 配置的用户本地版本。 Just copy the global netbeans.conf from the global snap location to your Netbeans user directory and make your changes there.只需将全局 netbeans.conf 从全局快照位置复制到 Netbeans 用户目录并在那里进行更改。

Example for version 11.3 of Netbeans: Netbeans 版本 11.3 的示例:

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. IE。 from 11.3 -> 12, etc.从 11.3 -> 12 等

This worked till 12.4 .这一直工作到12.4 Newer versions of the Snap package has changed the location of the NetBeans userdir so the script above would look like:较新版本的 Snap package 更改了 NetBeans 用户目录的位置,因此上面的脚本如下所示:

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.使用 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.但是,有一个解决方法:在启动 NetBeans 时使用--jdkhome参数传递要使用的 JDK 的路径。 For example, to start NetBeans 11.2 using JDK 8 on Windows on my PC:例如,要在我的 PC 上的 Windows 上使用 JDK 8 启动 NetBeans 11.2:

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

控制台启动

See Can I specify the JDK to run NetBeans on?请参阅我可以指定 JDK 以在其上运行 NetBeans 吗? for further details.了解更多详情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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