I tried to install leiningen ( 2.X.X ) and I noticed that it throws an error at execution (e.g lein version). I use java 7 on Ubuntu 20.04. Could you please provide me with some feedback on how to resolve this?
The error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: clojure/main : Unsupported major.minor version 52.0
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:1070)
at java.lang.ClassLoader.loadClass(ClassLoader.java:414)
at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
I tried different version of Leiningen (always 2.X.X, I didn't try 1.X.X versions) also downgrading Ubuntu. Unfortunately I can't change the java version because it is a project requirement.
Clojure requires at least Java 8:
Clojure depends on Java and all Clojure code is compiled to Java 8 compatible bytecode (newer versions of Java can load this as well).
Minimum runtime dependency: Java 8
Java 7 is over a decade old. To use a modern language you need tools that aren't ancient. If your project requirement is to use both Clojure and Java 7, then transitively it's a requirement that your project will fail.
Clojure since version
1.10
has Java8 as minimum.
Leiningen since 2.9
uses Clojure 1.10. So any version up to 2.8.3 should work just fine
with Java7.
And indeed it works fine for me using e.g. 2.7.1 (which I picked,
because it is the only <2.9 version still in SDKMAN):
% java -version
openjdk version "1.7.0_352"
OpenJDK Runtime Environment (Zulu 7.56.0.11-CA-linux64) (build 1.7.0_352-b01)
OpenJDK 64-Bit Server VM (Zulu 7.56.0.11-CA-linux64) (build 24.352-b01, mixed mode)
% lein -version
Leiningen 2.7.1 on Java 1.7.0_352 OpenJDK 64-Bit Server VM
(with Leiningen 2.10 the -version call fails with the same error as in
the question)
This of course also means, that you have to stick to plugins and deps
from before 2018 too.
All that said: Update! At some point even Azul will end the support...
Related
Cassandra 4 should work with java 11, but when I try to install it without java 8 then the installation fails:
error: Failed dependencies:
jre >= 1.8.0 is needed by cassandra-4.0.4-1.noarch
How can I get around this?
My current workaround is to install both java 8 and java 11, that way I satisfy the dependency requirement and can run cassandra 4 with java 11. However, there must surly be a better way?
I would of course prefer to only have java 11 installed.
Some extra info:
I use CentOs 7 and RHEL 8
Cassandra rpm downloaded from https://downloads.apache.org/cassandra/redhat/40x/
java -version
openjdk version "11.0.9.1" 2020-11-04 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.9.1+1-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9.1+1-LTS, mixed mode, sharing)
Since JRE is no longer available in Java 11 (JDK 11 release notes):
In this release, the JRE or Server JRE is no longer offered. Only the JDK is offered.
we probably shouldn't require the JRE as a dependency on CentOS and RHEL platforms:
Requires: jre >= 1.8.0
As a workaround, you can override the dependency check when installing the RPM with the --nodeps option. For example:
$ sudo rpm --nodeps -i cassandra-4.0.4-1.noarch.rpm
In the meantime, I've logged CASSANDRA-17669 for resolution. Cheers!
I'm running s simple pyspark python script in Pycharm, whithin an anaconda env with Python 3.7 (pyspark version 2.4.4) and I got error :
pyspark.sql.utils.IllegalArgumentException: 'Unsupported class file major version 55'.
I've followed the potential solutions I found on stackoverflow but non of them works, I followed this one:
https://stackoverflow.com/a/54704928/12375559: I've added java1.8.0_221 in my system env variables:
but when I type java -version in Pycharm terminal it's still using java11.0.6:
>java -version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+8-b765.1)
OpenJDK 64-Bit Server VM (build 11.0.6+8-b765.1, mixed mode)
Then I found this:
Pyspark throws IllegalArgumentException: 'Unsupported class file major version 55' when trying to use udf switch boot jdk of Pycharm (2xshift -> jdk -> select jdk 1.8)
So I navigated to Pycharm Switch IDE Boot JDK:
I can see the second option is 1.8 but without anaconda plugin, so I'm not sure what to do now because I don't want to mess up with my settings, might someone be able to help me please? Many thanks!
The 55 error is caused by an older Java version trying to execute Java version 11 code (in a .jar or .class file). So it seems like an older Java version (for example Java 8 (a JVM 8)) is used, but it encounters a part compiled in Java 11 (see 55 is Java 11).
Since Java 8 is less well supported, you could try to use Java 11 or newer (see Java version history). You could try to use PySpark 3.0.1 with Python 3.8 and Java 11. That way, you have recent parts that should be able to work together.
These links might also be helpful:
Specify Java version in a Conda environment
Spark Error - Unsupported class file major version
I'm doing this project where I have a webservice done in Java (HttpServlet) that uses Hibernate to select, insert and update information into a database and return an array of objects as JSON to whoever connects to the JSON endpoint.
I created it on my local computer and it works fine. However, I'm now trying to see how it would work on an actual server instead of locally.
So I connected through SSH to the server and copied the .war build to the Tomcat webapps folder, tried to run it, then I got the below error:
javax.servlet.ServletException: Servlet execution threw an exception
root cause java.lang.UnsupportedClassVersionError: org/hibernate/HibernateException : Unsupported major.minor version 52.0 (unable to load class org.hibernate.HibernateException)
So naturally I looked on StackOverflow to see what this error is about and I found that it's when you create your project in one version of Java and try to run the project on an inferior java machine. And I did that, indeed.
I created my project using Java 8 and I was running it on Java 7, on the server. So I updated the server to use Java 8. However, after updating to Java 8, I still get the same error.
If I run the java -version command, here's what I get:
LOCAL COMPUTER:
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
SERVER:
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
As you can see, I have java 1.8.0_121 on my local machine and java 1.8.0._111 on the server. Do you think there's any chance that that is the problem? Aren't they both Java 8?
Also, how does Tomcat know which java to use? I have 3 versions on the server (2 versions of the Java 7 and one version of the Java 8, java 1.8.0_111). How does Tomcat know which one to use?
To choose which one to use I used the sudo update-alternatives --config java command and chose the 1.8.0_111 version from there (the server is Ubuntu 12.04).
The problem is - I keep getting that error: java.lang.UnsupportedClassVersionError: org/hibernate/HibernateException : Unsupported major.minor version 52.0 (unable to load class org.hibernate.HibernateException) - and I can't run my project on the server.
Any suggestions?
When I got this error few days back, I had different versions of JDK and JRE running on my machine. I rectified it by setting the correct JRE path in Project's Build Path and also in the Window Preferences->Java->Installed JRE's. Also if you go to setenv.bat in your Tomcat\bin, there you specify which version of java should the Tomcat use by specifiying this:
set "JRE_HOME=%ProgramFiles%\Java\jre1.8.0_121", (obv, your version might be different so change that accordingly).
I hope that answers your query!
Edit: If you are wondering what setenv.bat is, refer: https://docs.oracle.com/cd/E40518_01/integrator.311/integrator_install/src/cli_ldi_server_config.html it explains what this bat file should contain.
As per the Documentation,
Hibernate 5.2 and later versions require at least Java 1.8 and JDBC 4.2.
Hibernate 5.1 and older versions require at least Java 1.6 and JDBC 4.0.
When building Hibernate 5.1 or older from sources, you need Java 1.7 due to a bug in the JDK 1.6 compiler.
When I type scala on the terminal to start the repl, it throws this error
scala> [init] error: error while loading AnnotatedElement,
class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar
(java/lang/reflect/AnnotatedElement.class)'
is broken (bad constant pool tag 15 at byte 2713)
When I hit enter and type println("hello, world"), it again throws this
error: error while loading CharSequence,
class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar
(java/lang/CharSequence.class)' is broken
(bad constant pool tag 15 at byte 1501)
I am using Ubuntu 14.04 and java -version gives
java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
Either update to a newer scala version (2.10.3+) or downgrade java to java 6/7. As you have seen in the output, 2.9.2 was here long before java 8 was introduced (Copyright 2002-2011, LAMP/EPFL), so they don't work well together.
This duplicate question contains exact instructions on ubuntu's java downgrade.
remove the scala 2.9.2 using terminal
sudo apt-get remove scala
download the latest scala from scala website
Installation instruction are giving on this link
You might have to run it with JDK 7 or 6
Downgrading JDK version to 7 solved this issue for me.
Here is the solution:
https://askubuntu.com/questions/761127/how-do-i-install-openjdk-7-on-ubuntu-16-04-or-higher
I was doing my homework in eclipse and it reported no errors, not even warnings. When I tried to compile it from terminal I got following error. It runs and compiles just fine with eclipse. I take it it has something to do with java version? Anyway to fix it or try to bypass it?
vedran#vedran-debian:~/java/oop/Aufgabe6$ java Test
Exception in thread "main" java.lang.UnsupportedClassVersionError: Test : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Test. Program will exit.
Java version:
java version "1.6.0_23"
OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-1)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
EDIT:
Thank you all for your explanations. It seems to be a java6/7 issue. I just compiled it with 1.6 and it worked like charm.
The Test.class file has been compiled in Java 7 (major/minor version 51.0), so it's incompatible with the Java 6 (major/minor version 50.0) runtime. Either compile the .java file in Java 6 (or earlier), or run the .class in a Java 7 runtime.
Maybe your Compiler in eclipse is different? Preferences -> Compiler: Compiler level. Maybe Java 7?
If you are under Linux, you can have a look for all your installed runtime environments: update-alternatives --config java. Here you can choose the correct one. Here you should be able to find the OpenJDK 7.
51.0 indicates Java version 7, so the class file you're trying to run was compiled with a version 7 compiler. If you need to run the code with a version 6 JVM you should instruct the compiler to emit version 6 compatible byte code.
javac -version 6 ...
That command line argument will force a higher version compiler to restrict its output to bytecode that's compatible with a version 6 runtime environment.
In Eclipse, go to Window-->Preferences-->Java-->Compiler and you will see a field labeled "Compiler compliance level". Set it to 1.6, and recompile in Eclipse.
There is a Java version mismatch between Eclipse and your command-line javac. Specifically, your javac seems to be using 64-bit 1.6. Eclipse apparently is using 1.7.
Is it possible you've compiled your Test program Java 7 and are now attempting to run it against Java 6 in the terminal? I would try recompiling in the terminal (ie. Java 6) if that's the case and then attempt to re-run the program.
If solutions above are all set , if u still have the same issue and
if your using MAVEN then check in the pom.xml. JAVA ASSIST JAR should point 16.1-GA if your using jdk 1.6 else corresponding version should be added for the jdk that you are pointing to.(eg : 3.17.1 for jdk 7).For jdk 6 add the dependency with the following details
groupId : org.javassist
artifactId: javassist
version : 3.16.1-GA