Skip to content
Advertisement

Cannot run Launch4j (illegal access)

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

Advertisement

Answer

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 
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement