不能运行Launch4j(非法访问)

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

Cannot run Launch4j (illegal access)

问题

我想为我的Java桌面应用程序创建一个.exe文件。因此,我看到Launch4j是最佳选项。

当我运行文件时,我收到以下错误消息。

警告:发生了非法的反射访问操作
警告:非法的反射访问来自com.thoughtworks.xstream.core.util.Fields(文件:/usr/local/Cellar/launch4j/3.12/libexec/lib/xstream.jar)对java.util.Properties.defaults字段
警告:请考虑向com.thoughtworks.xstream.core.util.Fields的维护者报告此问题
警告:使用--illegal-access=warn来启用进一步非法的反射访问操作的警告
警告:所有非法的访问操作将在将来的版本中被拒绝
主线程中的异常"main"java.lang.NoClassDefFoundError:com/sun/java/swing/plaf/windows/WindowsLookAndFeel
at java.base/java.lang.ClassLoader.defineClass1(本机方法)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at net.sf.launch4j.Main.main(Main.java:59)由于:java.lang.ClassNotFoundException:com.sun.java.swing.plaf.windows.WindowsLookAndFeel
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)... 10个以上

我正在使用Mac OS Catalina,版本10.15.3。
我的Java版本环境是:
openjdk版本"11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK(版本11.0.7+10)
OpenJDK 64位服务器VM AdoptOpenJDK(版本11.0.7+10,混合模式)

如果您有其他可以完成工作的程序,我将很高兴知道。
实际上,我正在寻找适用于两个操作系统(Windows和Mac)的等效于InnoSetup的东西。

感谢您的帮助。

英文:

I would like to create an .exe file for my java desktop application.
Hence, i saw that Launch4j was the best option.

When I ran. the file, i have the following error message.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/usr/local/Cellar/launch4j/3.12/libexec/lib/xstream.jar) to field java.util.Properties.defaults
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/java/swing/plaf/windows/WindowsLookAndFeel
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
 	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) 
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) 
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) 
	at net.sf.launch4j.Main.main(Main.java:59) Caused by: java.lang.ClassNotFoundException: com.sun.java.swing.plaf.windows.WindowsLookAndFeel 
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) 	
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) 	... 10 more

I am working under Mac OS Catalina, version 10.15.3.
and my Java version environment:
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)

If you have any other program that could do the job, i'll be glad to know.
In fact, i am looking for something equivalent to InnoSetup for both OS (Windows and Mac)

Thank you for the help

答案1

得分: 0

我遇到了相同的错误,并在寻找解决方案时发现了你的问题。

最终,我通过从 https://jdk.java.net/archive/ 下载 openJDK 9.0.4 来成功运行 launch4j。

手动使用这个 Java 版本运行 launch4j.jar 的命令如下:

jdk-9.0.4.jdk/Contents/Home/bin/java -jar ~/Downloads/launch4j/launch4j.jar
英文:

I had this same error and found your question looking for a solution.

I ended up getting launch4j running by downloading openJDK 9.0.4 from the archive at https://jdk.java.net/archive/.

Running the launch4j.jar manually with this java version worked as expected:

jdk-9.0.4.jdk/Contents/Home/bin/java -jar ~/Downloads/launch4j/launch4j.jar 

答案2

得分: 0

如果您正在使用Java 11并且在Linux上使用,请下载并安装另一个Java版本。我安装了Java 8。

运行命令 "sudo update-alternatives --config java" 来列出计算机上安装的所有Java版本。该命令将提供更改默认Java版本的选项。

将Java版本从11更改为8(我不确定其他版本是否有效)。

重新运行命令 java -jar launch4j。它应该可以工作。

英文:

If you are using java 11 and using Linux, download and install another java version. I installed java 8.

Run the command "sudo update-alternatives --config java" to list all the java versions installed in your computer. The command will provide an option to change the default java version.

Change from 11 to 8(Am not sure if any other version will work).

Rerun the command java -jar launch4j. It should work

不能运行Launch4j(非法访问)

huangapple
  • 本文由 发表于 2020年7月29日 20:38:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/63153800.html
匿名

发表评论

匿名网友

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

确定