Java 安装 NetBeans 时如何修复错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/60771107/
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 01:22:19  来源:igfitidea点击:

How to fix error while installing NetBeans?

javanetbeans

提问by Clairexxp

I have installed Java and am trying to install NetBeans 11.3 on my Windows 10 but after I ran the exe. installer, an error message popped up:

我已经安装了 Java 并且正在尝试在我的 Windows 10 上安装 NetBeans 11.3,但是在我运行了 exe 之后。安装程序,弹出错误消息:

An unexpected exception happened in thread main java.lang.NoClassDefFoundError java/util/jar/Pack200

线程主 java.lang.NoClassDefFoundError java/util/jar/Pack200 中发生意外异常

采纳答案by José Ramón Mendoza Ortiz

NetBeans have problems with the jdk-14, because I suppose that you have install the jdk-14 so uninstall it and try it with the jdk-13.0.2.

NetBeans 在 jdk-14 上有问题,因为我想你已经安装了 jdk-14,所以卸载它并用 jdk-13.0.2 试试。

回答by user13122936

The https://netbeans.apache.org/download/nb113/nb113.htmlsite now has this memo:

https://netbeans.apache.org/download/nb113/nb113.html网站现在有这个备忘录:

The installers will not run under JDK 14 because usage is made of the Pack200 Tools and API, for packing and unpacking, which is removed in JDK 14, see JEP 367.

安装程序不会在 JDK 14 下运行,因为使用 Pack200 工具和 API 进行打包和解包,在 JDK 14 中已删除,请参阅 JEP 367。

回答by Chili

If several JDK versions are installed, then you need to define the environment variable "JAVA_HOME" where to set the path to JDK-12. Details are described here. (Only in Russian)

如果安装了多个JDK版本,则需要定义环境变量“JAVA_HOME”,其中设置JDK-12的路径。此处描述详细信息。(仅限俄语)

回答by Felistrix

Sorry, but in my opinion is to install an old version from Java no solution, just because it works. When someone has problems with his Firewall, simply disable the Firewall would also be no solution.

抱歉,但在我看来是从 Java 安装旧版本没有解决方案,只是因为它有效。当某人的防火墙出现问题时,简单地禁用防火墙也无济于事。

https://www.java.com/en/download/faq/other_jreversions.xml
We highly recommend users remove all older versions of Java from your system. Keeping old and unsupported versions of Java on your system presents a serious security risk. Removing older versions of Java from your system ensures that Java applications will run with the most up-to-date security and performance improvements on your system.

https://www.java.com/en/download/faq/other_jreversions.xml
我们强烈建议用户从您的系统中删除所有旧版本的 Java。在您的系统上保留旧的和不受支持的 Java 版本会带来严重的安全风险。从您的系统中删除旧版本的 Java 可确保 Java 应用程序将在您的系统上以最新的安全性和性能改进运行。

The "real" solution would be a reprogramming of the NetBeans installer. This used function was suggested for deprecated on 2018-04-04, which was done on 2018-08-23.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8200752
The removal was suggested on 2019-10-08, which was done on 2019-12-18.
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232022

“真正的”解决方案是重新编程 NetBeans 安装程序。建议在 2018-04-04 弃用此使用的功能,该功能已于 2018-08-23 完成。
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8200752
于 2019-10-08 建议移除,该移除于 2019-12-18 完成。
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232022

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232022
We assume that developers who rely on Pack200 have had enough notice about its proposed removal to make alternative arrangements. … We assume that developers who use pack200to shrink application JARs can switch to either the jlinktool or the jpackagetool to create application-specific runtimes with an optimized form factor.

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8232022
我们假设依赖 Pack200 的开发人员已经对其提议的移除有足够的了解,以便做出替代安排。……我们假设使用pack200缩小应用程序 JAR 的开发人员可以切换到jlink工具或jpackage工具来创建具有优化外形的应用程序特定运行时。

edit: I solved it this way.

编辑:我是这样解决的。

  1. uninstalled JDK 14
  2. installed JDK 13.0.2
  3. installed Apache NetBeans
  4. installed JDK 14
  5. open C:\Program Files\NetBeans\netbeans\etc\netbeans.conf and changed path to JDK
  6. uninstalled JDK 13.0.2
  1. 卸载 JDK 14
  2. 安装了 JDK 13.0.2
  3. 已安装 Apache NetBeans
  4. 安装了 JDK 14
  5. 打开 C:\Program Files\NetBeans\netbeans\etc\netbeans.conf 并将路径更改为 JDK
  6. 卸载 JDK 13.0.2

Now NetBeans runs with the JDK 14.

现在 NetBeans 与 JDK 14 一起运行。

回答by Andy

Yes, I got it working as follows from cmd, when referring to older version: Apache-NetBeans-11.3-bin-windows-x64.exe --javahome "C:\Program Files\Java\jdk-12.0.2"

是的,当提到旧版本时,我从 cmd 中按如下方式工作:Apache-NetBeans-11.3-bin-windows-x64.exe --javahome "C:\Program Files\Java\jdk-12.0.2"

回答by Nite

An alternate way to Andy's.
(Windows)
1) Right click on "Apache-NetBeans-11.3-bin-windows-x64" installer and select "Create shortcut".
2) Right click on the created shortcut and select "Properties".
3) In the "target" textbox, add your under 14 JDK version path at the end, here is how mine looks like:

安迪的另一种方式。
(Windows)
1) 右键单击​​“Apache-NetBeans-11.3-bin-windows-x64”安装程序并选择“创建快捷方式”。
2) 右键单击​​创建的快捷方式并选择“属性”。
3)在“目标”文本框中,在最后添加您的JDK 14以下版本路径,这是我的样子:

C:\Users\userfoldername\Desktop\Apache-NetBeans-11.3-bin-windows-x64.exe --javahome "C:\Program Files\Java\jdk-13"

C:\Users\userfoldername\Desktop\Apache-NetBeans-11.3-bin-windows-x64.exe --javahome "C:\Program Files\Java\jdk-13"

4) Press Ok when done, double-click on the shortcut and it should install fine now.

4)完成后按确定,双击快捷方式,现在应该可以正常安装了。

回答by John Breland

Switching to openJDK 12 worked for me too. But instead of uninstalling JDKs or manually changing the env, I use Sdkman.iowhich works like Node version manager if you have used that. It manages your JDKS for you and offers downloads of different versions (Open, Zulu, Graals) and will switch between them with with just a quick command.

切换到 openJDK 12 也对我有用。但是,我没有卸载 JDK 或手动更改 env,而是使用Sdkman.io,如果您使用它,它的工作方式类似于 Node 版本管理器。它为您管理 JDKS 并提供不同版本(Open、Zulu、Graals)的下载,并且只需一个快速命令即可在它们之间切换。