找不到java。请使用 --jdkhome 开关

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29052219/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 07:15:54  来源:igfitidea点击:

Cannot find java. Please use the --jdkhome switch

javanetbeanscentos

提问by OtagoHarbour

I have just installed Netbeans 8.0.2 on CentOS 6.5.

我刚刚在 CentOS 6.5 上安装了 Netbeans 8.0.2。

When I try to run it, I get the message

当我尝试运行它时,我收到消息

Cannot find java. Please use the --jdkhome switch

I have /usr/share/java-1.7.0 so I typed

我有 /usr/share/java-1.7.0 所以我输入

/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /usr/share/java-1.7.0

and still got

并且仍然得到

Cannot find java. Please use the --jdkhome switch

I also have /root/Downloads/jdk1.8.0_40 which allowed me to install Netbeans. However, when I type

我还有 /root/Downloads/jdk1.8.0_40 允许我安装 Netbeans。但是,当我输入

/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /root/Downloads/jdk1.8.0_40

I still get

我仍然得到

Cannot find java. Please use the --jdkhome switch

I tried

我试过

whereis java

and got

并得到

java: /usr/bin/java /etc/java /usr/lib/java /usr/share/java /usr/share/man/man1/java.1.gz

However

然而

/usr/local/netbeans-8.0.2/bin/netbeans --jdkhome /usr/bin/java

still produces

仍然产生

Cannot find java. Please use the --jdkhome switch.

采纳答案by Crazyjavahacking

I do recommend you to change the configuration of JDK used by NetBeans in netbeans.confconfig file:

我建议您在netbeans.conf配置文件中更改 NetBeans 使用的 JDK配置

netbeans_jdkhome="C:\Program Files\Java\..."

回答by ntm

Check the setting in your user config /home/username/.netbeans/version/etc/netbeans.conf

检查用户配置中的设置 /home/username/.netbeans/version/etc/netbeans.conf

I had the problem where I was specifying the location globally, but my user setting was overriding the global setting.

我在全局指定位置时遇到了问题,但我的用户设置覆盖了全局设置。

CentOS 7/Netbeans 8.1

CentOS 7/Netbeans 8.1

回答by Maruf Hamidi

  1. Go to the netbeans installation directory
  2. Find configuration file [installation-directory]/etc/netbeans.conf
  3. towards the end find the line netbeans_jdkhome=...
  4. comment this line line using '#'
  5. now run netbeans. launcher will find jdk itself (from $JDK_HOME/$JAVA_HOME) environment variable
  1. 进入netbeans安装目录
  2. 找到配置文件【安装目录】/etc/netbeans.conf
  3. 最后找到行 netbeans_jdkhome=...
  4. 使用 '#' 注释此行
  5. 现在运行netbeans。启动器会找到 jdk 本身(来自 $JDK_HOME/$JAVA_HOME)环境变量

example:

例子:

sudo vim /usr/local/netbeans-8.2/etc/netbeans.conf

回答by dirk

NetBeans 8.2 - Cannot locate java installation in specified jdkhome?

NetBeans 8.2 - 无法在指定的 jdkhome 中找到 java 安装?

Answer: Edit the netbeans.conf file.

答:编辑 netbeans.conf 文件。

Close NetBeans, start Notepad or another text editor as Administrator. Right click on the Notepad application and choose "Run as administrator" and then open netbeans.conf with it. Change netbeans_jdkhome=”C:\Program Files...whatever”.

关闭 NetBeans,以管理员身份启动记事本或其他文本编辑器。右键单击记事本应用程序并选择“以管理员身份运行”,然后用它打开 netbeans.conf。更改 netbeans_jdkhome=”C:\Program Files...whatever”。

回答by Sus20200

Try Java SE Runtime Environment 8. It fixed it for me.

尝试 Java SE Runtime Environment 8。它为我修复了它。

回答by Almir Campos

ATTENTION MAC OS USERS

注意 MAC 操作系统用户



First, please remember that in a Mac computer the netbeans.conffile is stored at

首先,请记住,在 Mac 计算机中,netbeans.conf文件存储在

/Applications/NetBeans/NetBeans 8.2.app/Contents/Resources/NetBeans/etc/netbeans.conf

(if you had used the default installation package.)

(如果您使用的是默认安装包。)

Then, also remember that the directoryyou MUSTuse on either "netbeans_jdkhome" or "--jdkhome"it's NOTthe /Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/but the following one:

然后,也请记住,目录,你必须上既可以使用“netbeans_jdkhome”或“--jdkhome”这是不是/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/但下面的一个

/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home //<-- Please, notice the /Contents/Home at the end. That's the "trick"!

Note: of course, you must change the versions for both NetBeans and JDK you're using.

注意:当然,您必须更改正在使用的 NetBeans 和 JDK 的版本。

回答by Franc Drobni?

With the Netbeans 10, commenting out the netbeans_jdkhomesetting in .../etc/netbeans.confdoesn't do the job anymore. It is necessary to specify the right directory depending of 32/64 bitness.

使用 Netbeans 10,注释掉 中的netbeans_jdkhome设置.../etc/netbeans.conf不再起作用。有必要根据 32/64 位指定正确的目录。

E.g. for 64 bit application: netbeans_jdkhome="C:\Program Files\AdoptOpenJDK\jdk8u202-b08"

例如对于 64 位应用程序: netbeans_jdkhome="C:\Program Files\AdoptOpenJDK\jdk8u202-b08"

回答by f1vlad

What worked for me is:

对我有用的是:

  • make sure javapath is available:
  • 确保java路径可用:
$ which java
/usr/bin/java
  • then in etc/netbeans.conf make sure netbeans_jdkhomeis commented out
  • in Finder go to /bin/ click on netbeans (terminal icon)
  • 然后在 etc/netbeans.conf 中确保netbeans_jdkhome被注释掉
  • 在 Finder 中转到 /bin/ 单击 netbeans(终端图标)

You would expect ./netbeans --jdkhome=/usr/bin/javato work, but it doesn't for some reason.

你会期望./netbeans --jdkhome=/usr/bin/java工作,但它不是出于某种原因。

回答by Captain A

If like me, you got that message after installing jenv, simply add netbeans_jdkhome="$JAVA_HOME"to your [netbeans-installation-directory]/etc/netbeans.conffile

如果像我一样,您在安装jenv后收到该消息,只需将其添加netbeans_jdkhome="$JAVA_HOME"到您的[netbeans-installation-directory]/etc/netbeans.conf文件中

回答by Mark Jeronimus

In my case, I had installed *ahem* OpenJDK, but the bin folder was full of symlinks to the bundled JRE and the actual JDK was nowhere to be found.

就我而言,我已经安装了 *ahem* Open JDK,但是 bin 文件夹中充满了指向捆绑 JRE 的符号链接,而实际的 JDK 无处可寻。

When I see a directory structure with binand jresubdirectories I expect this to be the JDK installation, because JRE installations on Windows looked different. But in this case it was the JRE installation as found out by apt search. After installing openjdk-8-jre the simlinks were replaced and the directory structure otherwise stayed the same.

当我看到包含binjre子目录的目录结构时,我希望这是 JDK 安装,因为 Windows 上的 JRE 安装看起来不同。但在这种情况下,它是由apt search. 安装 openjdk-8-jre 后,simlinks 被替换,目录结构保持不变。