Description
Following the Getting Started with the Closure Compiler Application page I installed Java Version 8 Update 431 (64-bit) for Windows 11. Installed on disk in the confusing directory C:\Program Files\Java\jre1.8.0_431
Getting the latest closure-compiler
from Maven repository (closure-compiler-v20240317.jar)
Running with
java -jar closure-compiler-v20240317.jar -js somefile.js --compilation_level ADVANCED_OPTIMIZATIONS
I get the error
Exception in thread "main" java.lang.UnsupportedClassVersionError:
com/google/javascript/jscomp/CommandLineRunner has been compiled by a more recent version of the Java Runtime (class file version 55.0),
this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Looking at some other issues I found that there is also a closure-compiler-unshaded
version. Searching on Maven I downloaded closure-compiler-unshaded-v20240317.jar
Running with
java -jar closure-compiler-unshaded-v20240317.jar -js somefile.js --compilation_level ADVANCED_OPTIMIZATIONS
I get the error
no main manifest attribute, in /path/to/closure-compiler-unshaded-v20240317.jar
If I go back a few versions I can use the v20211201
without error.
What is the difference between closure-compiler
and closure-compiler-unshaded
?
Why does closure-compiler-v20240317
have a main manifest attribute
but closure-compiler-unshaded-v20240317
not?
How to run closure-compiler
with JavaRE 8u431?
Fixing the missing main manifest attribute
in closure-compiler-unshaded-v20240317
results in a java.lang.ClassNotFoundException
exception.
Even going back to 2013 that line, if present in the jar MANIFEST, is
Main-Class: com.google.javascript.jscomp.CommandLineRunner