在 MacOS Big Sur 上安装 Netbeans 8.2 时未找到 JDK。

huangapple go评论93阅读模式
英文:

Installing Netbeans 8.2 on MacOS Big Sur no JDK found

问题

我最近升级到了MacOS Big Sur,当我尝试打开NetBeans 8.2时出现了错误:

缺少JDK,并且需要运行一些NetBeans模块。请使用--JDK主目录命令选项指定JDK安装位置。

我尝试将JAVA_HOME设置为JDK路径,但没有成功。因此,我卸载了NetBeans和JDK,然后重新下载了NetBeans 8.2和JDK 8。

现在尝试设置NetBeans时,显示如下:

> 无法安装NetBeans IDE。您计算机上找到了Java(JRE),但需要JDK 8或更新版本。请从http://www.oracle.com/technetwork/java/javase/downloads/index.html下载并安装JDK 8的最新更新,然后重新启动NetBeans安装。

Java -version

java版本 "1.8.0_271"
Java(TM)SE Runtime Environment(构建1.8.0_271-b09)
Java HotSpot(TM)64位服务器VM(构建25.271-b09,混合模式)

Javac -version

javac 1.8.0_271

我当前的**$JAVA_HOME**被设置为/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home

我还尝试使用JDK 14和15安装NetBeans 11和12,但仍然出现相同的错误。

编辑:
以下是唯一对我有效的解决方案。

/Applications/NetBeans/Apache\ NetBeans\ 12.1.app/Contents/Resources/NetBeans/netbeans/bin/netbeans --jdkhome /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
  1. 将上述命令粘贴到终端。它会打开NetBeans。要在不再次键入命令的情况下使用NetBeans,请将上述命令保存在代码编辑器中,然后另存为NetBeans.command文件。

  2. 然后打开该文件。在提示的消息上点击确定。在终端上键入以下命令。

    sudo passwd root

  3. 输入您的登录密码。

  4. 只需按下Enter(无需输入新密码)

  5. 键入su root和您的登录密码。

  6. 键入chmod +x <保存带有.command的文件的路径>。退出终端并打开保存的文件。现在应该可以正常工作。

英文:

I have recently upgraded into MacOS Big Sur and when tried to open NetBeans 8.2 it gave an error

The JDK is missing and is required to run some NetBeans modules. Please use the --JDK home command-line option to specify a JDK installation

I tried setting JAVA_HOME to the JDK path but it didn't work. So, I uninstalled Netbeans and JDK and re-downloaded Netbeans 8.2 and JDK 8.

Now when trying to set up the Netbeans, it shows :

> NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK 8 or newer is required. Please download and install the latest update of JDK 8 from http://www.oracle.com/technetwork/java/javase/downloads/index.html and restart NetBeans installation.

Java -version

java version &quot;1.8.0_271&quot;
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

Javac -version

javac 1.8.0_271

My current $JAVA_HOME is set to/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home

I also tried installing NetBeans 11 and 12 with JDK 14 and 15 but it gives the same error

EDIT:
Following is the only solution that worked for me.

/Applications/NetBeans/Apache\ NetBeans\ 12.1.app/Contents/Resources/NetBeans/netbeans/bin/netbeans --jdkhome /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home
  1. Paste the above command on terminal. It opens the NetBeans. To use the NetBeans without typing the command again save the above command on a code editor and save as NetBeans.command file.

  2. Then open the file. Click okay on the prompted message. Type following command on the terminal.

    sudo passwd root

  3. Type your login password.

  4. Just press Enter (you don't have to type a new password)

  5. Type su root and your login password again.

  6. Type chmod +x &lt;path of the file you saved with .command&gt;. Quit the terminal and open the saved file. It should work now.

答案1

得分: 9

我遇到了同样的问题。
我不需要重新启动计算机。
我只是在文件netbeans.conf中更改了这一行:

netbeans_jdkhome="/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home"

从目录中:

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

这对我起效了。

英文:

I had the same problem.
I have not needed to restart the computer.
I have simply changed the line:

netbeans_jdkhome=&quot;/Library/Java/JavaVirtualMachines/jdk1.8.0_211.jdk/Contents/Home&quot;

in the file netbeans.conf, from the directory:

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

and this has worked for me

答案2

得分: 5

我安装Netbeans时遇到了相同的问题。以下方法适用于我:

在终端中运行以下命令:

brew install netbeans

英文:

I got the same issue when I could install Netbeans. And this works for me:

run this command line in terminal:

> brew install netbeans

答案3

得分: 4

问题似乎在于 /usr/libexec/java_home 在 BigSur 中出现问题(参见这里:https://developer.apple.com/forums/thread/666681)。

Netbeans 安装程序通过使用 /usr/libexec/java_home 来检查是否安装了 JDK,然后得到错误的答案并退出并显示错误。

修复这个行为的一种方法是修补安装程序。可以按以下方式进行:

假设 tmp 目录下没有名为 "a" 的目录:

  1. 打开 dmg 文件,但不要运行安装程序。

  2. 在 shell 中执行以下命令:

pkgutil --expand /Volumes/NetBeans\ 8.2\ RC/NetBeans\ 8.2\ RC.pkg /tmp/a

(如果你的 Netbeans 安装程序有不同的名称,请根据实际名称更改命令)

这会打开软件包,并将其内容复制到 /tmp/a 中。

  1. 编辑安装脚本。使用文本编辑器打开文件 /tmp/a/Distribution。

  2. 在第13行,将:

var java_result = checkJavaVersion();

替换为:

var java_result = true;

然后保存文件。这将跳过对 Java 版本的检查。你需要确保你的计算机上安装了 JDK 8 或更高版本,并且在使用 java 命令时使用了该版本。你可以通过以下命令确认:

java -version

  1. 完成:

pkgutil --flatten /tmp/a ~/a.pkg

此时,你的用户目录中会有一个名为 a.pkg 的软件包。双击它,Netbeans 安装程序将完成其工作。

英文:

The problem seems to be the fact that /usr/libexec/java_home seems to be broken in BigSur (see here: https://developer.apple.com/forums/thread/666681).

The Netbeans installer checks if the JDK is installed by using /usr/libexec/java_home, gets the wrong answer and quits with an error.

One way to fix that behaviour is to patch the installer. It can be done as follows:

assuming there is no directory called "a" in tmp:

  1. Open the dmg, but do not run the installer

  2. In a shell give the following command:

pkgutil --expand /Volumes/NetBeans\ 8.2\ RC/NetBeans\ 8.2\ RC.pkg /tmp/a

(if your Netbeans installer has a different name, change the command to reflect the actual name of your installer)

This opens the package, and copies it s content in /tmp/a.

  1. Edit the installation script. Using a text editor, open the file /tmp/a/Distribution.

  2. on line 13, replace:

var java_result = checkJavaVersion();

with

var java_result = true;

and save the file. This will skip the check on the Java version.
It is your responsibility to make sure you have JDK 8 or following on your machine, and that this version is used when you use the java command. You can make sure that's fine by checking with the command

java -version

  1. Let's wrap it up:

pkgutil --flatten /tmp/a ~/a.pkg

At this point you have in your home directory a package called a.pkg. Double click on it, and the Netbeans installer will do its job.

答案4

得分: 2

这对我有用:
从新安装开始使用Java。

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/Java/JavaVirtualMachines
sudo rm -rf /Library/Application\ Support/Oracle/Java/
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane

重启电脑。

下载并安装Java jdk-8u271-macosx-x64
重启电脑。

从Apache NetBeans下载并安装NetBeans 12.1(抱歉,NetBeans 8.2对我来说不再可用,尽管我起初尝试过)。

打开NetBeans,在NetBeans 8.2首选项中导入。
转到NetBeans菜单下的NetBeans首选项窗格。
点击Java图标,然后点击Java Shell...等待NetBeans响应。接受任何对话框(我忘了,但会出现一些对话框)。
NetBeans会抱怨找不到jdk;退出NetBeans。
用bbedit或类似的工具打开文件/Applications/NetBeans/NetBeans 12.1.app/Contents/Resources/NetBeans/etc/netbeans.conf
找到并编辑以下行:

netbeans_jdkhome=&quot;/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home&quot;

保存文件。
打开NetBeans;转到NetBeans菜单下的NetBeans首选项窗格。
点击Java图标,然后点击Java Shell。它可能会停留在空白方块上。
关闭首选项窗格;转到工具菜单:您会看到Java平台菜单,进入其中。
就是这样,所有的Java安装都在那里。

希望这能有所帮助。

英文:

This worked for me:
Start Java from fresh installation.

sudo rm -rf /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -rf /Library/Java/JavaVirtualMachines
sudo rm -rf /Library/Application\ Support/Oracle/Java/
sudo rm -rf /Library/PreferencePanes/JavaControlPanel.prefPane

Restart computer.

Download and install Java jdk-8u271-macosx-x64
Restart computer.

Download and install NetBeans 12.1 from Appache Netbeans (sorry, Netbeans 8.2 didn’t worked anymore for me, though I tried at first).

Open Netbeans, do acepte import Netbeans 8.2 preferences.
Go to Netbeans Preferences pane under Netbeans menu.
Click on Java icon, then click on Java Shell... wait until Netbeans responds. Do accept any dialog (I forgot, but some dialog appears).
Netbeans will complain about jdk not being found; exit Netbeans.
Open file /Applications/NetBeans/NetBeans 12.1.app/Contents/Resources/NetBeans/etc/netbeans.conf with bbedit or something alike.
Find and edit line to this:

netbeans_jdkhome=&quot;/Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home&quot;

Save file.
Open Netbeans; go to Netbeans Preferences pane under Netbeans menu.
Click on Java icon, then click on Java Shell. It may stay at blank square.
Close Preferences Pane; go to Tools menu: You’ll see Java Platforms menu, go into it.
There you have, all Java installment.

Hepoe this helps.

答案5

得分: 1

这只是与NetBeans JDK主目录路径有关的问题,不用担心,尝试以下步骤 -

第一步 - 打开终端

/usr/libexec/java_home

输出 - /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

将此路径复制,因为您需要将其保存在netbeans.conf文件中

第二步 - 在终端中使用以下命令

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

搜索netbeansjdkhome,然后粘贴您在第一步中复制的路径

最终应如下所示 -

netbeansjdkhome=" /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home"

第三步 - 重新启动并打开NetBeans 8.2,现在应该可以正常工作。

英文:

Its just the issue with netbeans jdk home path not to worry try this -

Step 1 - Open Terminal

/usr/libexec/java_home

Output - /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home

Copy this path as you have to save this in netbeans.conf

Step 2 - In terminal use this

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

search for netbeansjdkhome and paste the path you copied in STEP 1

Finally it should look like this -

netbeansjdkhome=&quot;/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home&quot;

Step 3 - Restart and open Netbeans 8.2 it will work fine now.

答案6

得分: 0

这实际上非常简单!但是弄清楚这个真的很难!

我会一步一步地告诉你:

第1步:首先,你必须确保像这样设置JAVA_HOME(取决于你安装的版本):

export JAVA_HOME=$(/usr/libexec/java_home -v "1.8.0_275")

如果你不确定安装了哪个jdk版本,只需执行以下操作:

/usr/libexec/java_home -V

第2步:好的,现在你必须从Apache的网站上下载你想要安装的任何NetBeans版本。我需要11.1。

第3步:打开dmg文件,并将pkg文件复制到你的主目录中(你可以使用Finder或任何你想要的工具)。

第4步:在你的主目录上执行以下命令(确保用正确的信息替换youruser和yourpkgfilename.pkg):

/usr/bin/sudo -E -- /usr/bin/env LOGNAME=youruser USER=youruser USERNAME=youruser /usr/sbin/installer -pkg yourpkgfilename.pkg -target /

你应该会得到以下输出:

installer: 包名称为 Apache NetBeans IDE 11.1
installer: 正在安装到基本路径 /
installer: 安装成功。

附注:看到了吗,我刚刚注册了,只是为了确保帮助这里所有遇到同样问题的人,如果这真的对你有帮助,我会非常感谢如果被投票选为正确的解决方案,好吗?

英文:

It's actually quite easy! But it was really hard to figure it out!

i'll tell it step by step:

STEP 1: First of all you have to make sure you set JAVA_HOME like this (depending on the version you have installed:

export JAVA_HOME=$(/usr/libexec/java_home -v &quot;1.8.0_275&quot;)

If you're just not sure what jdk version you have installed in, just do this:

/usr/libexec/java_home -V

STEP 2: Ok, now you have to download the whatever netbeans version you wanna install from apache's website. I needed 11.1.

STEP 3: Open up the dmg file and copy the pkg file into your home directory (you can use finder or whatever you want).

STEP 4: Execute the following command on your home directory (make sure to replace youruser and yourpkgfilename.pkg with the right information):

/usr/bin/sudo -E -- /usr/bin/env LOGNAME=youruser USER=youruser USERNAME=youruser /usr/sbin/installer -pkg yourpkgfilename.pkg -target /

You should get this output:

installer: Package name is Apache NetBeans IDE 11.1
installer: Installing at base path /
installer: The install was successful.

PS: See, i've signed UP to this RIGHT NOW, just to make sure to help everybody in the same problem here, i would really appreciate to be voted as the right solution if this really helps you ok?

huangapple
  • 本文由 发表于 2020年10月23日 13:42:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/64494505.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定