Maven-install Unsupported Class Version Error - java

I have cloned a Maven repository which I wish to use and build on my machine. I used to be able to build this particular project, but now when I choose maven install, it gives me this error
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
Which is really strange. I know that this maven project uses java 6, and it shows so in the pom.xml, but my machine already has java 6 installed. In fact, the project says it's using it. What's going on?

Although your project uses Java 6, Maven version 3.3.3 (latest at this time) needs Java 7.
Either use Maven 3.2.5 (that uses Java 6) or install Java 7.
Reference:
https://maven.apache.org/docs/history.html

Related

JBoss Unsupported major.minor version 52.0

I have an application that needs to be deployed in JBoss 6.0.0 and I am using Eclipse Mars. My system variable points to Java 1.6, from build path I've selected Java 1.6 and also, JBoss is using Java 1.6. My problem is that when trying to deploy the app to JBoss the following error
[org.jboss.detailed.classloader.ClassLoaderManager] Unexpected error during load of:com.xservice.java.velocity.VelocityLoader: java.lang.UnsupportedClassVersionError: com/xservice/java/velocity/VelocityLoader : Unsupported major.minor version 52.0.
I don't have any idea how to handle this considering the given settings.
The problem was fixed by changing the Java version from Project Facets(it was 1.8 instead of 1.6). Thanks go to Sanjeev Saha.
Project facets screen
Please locate the Jar which contains the class com.xservice.java.velocity.VelocityLoader.
This class is compiled with JDK 8. The class file version for Java SE 8 is 52.0 as per http://www.oracle.com/technetwork/java/javase/8-compatibility-guide-2156366.html Your JVM is Java 6. You may not be able to run a Java class compiled with JDK 8.0 by JVM 6.0. This is the reason you are getting 'Unsupported major.minor version 52.0'
My suggestion is using a Jar which contains classes compiled by JDK 6.0.

Running Eureka Client with JDK 1.7

I am getting following error when running a eureka client discovery sample code.
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/netflix/servo/monitor/Monitors : Unsupported major.minor version 52.0
I guess this is probably due to the fact that eureka is compiled with Java 8 (52).
But does it mean that we can not use it with JDK 1.7 ? My project is in JDK7 and is it possible to run eureka(1) with JDK 1.7 ?
If you are running the official sample application use the correct dependencies, servo-core latest dependencies are compiled with JDK8, Use an older version
<dependency>
<groupId>com.netflix.servo</groupId>
<artifactId>servo-core</artifactId>
<version>0.10.0</version>
</dependency>
README.md says:
Building
The build requires java8 because of some required libraries that are
java8 (servo), but the source and target compatibility are still set
to 1.7.
Reference:
https://github.com/Netflix/eureka

Akka Hello World Problems - Unsupported major.minor version 52.0

I am trying to run this example using option 3. I think I was able to build the project using activator but failed when I tried to run it using ./activator run command. When trying to run this the console spits out this cryptic message that I would not find much information about on Google. Here is the error:[warn] Error reading API from class file : java.lang.UnsupportedClassVersionError: akka/actor/UntypedActor : Unsupported major.minor version 52.0
java.lang.UnsupportedClassVersionError: akka/actor/UntypedActor : Unsupported major.minor version 52.0
What does this mean?
I am using Java 7 JDK on a Linux Ubuntu laptop.
Regards,
This example contains a pom.xml so you can see which version of Akka is used: http://www.typesafe.com/activator/template/akka-sample-main-java?_ga=1.217401040.754558484.1443808082#code/pom.xml
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.4.0</version>
</dependency>
Akka 2.4.0 requires Java 8: http://akka.io/news/2015/09/30/akka-2.4.0-released.html
dropped support for Java 6 & 7 as announced in the last roadmap
update, and now require Java 8 or later—this will allow us to create
modern idiomatic Java APIs over the course of the upcoming releases
Therefore it is not just this example which will not work. Any akka code which uses akka 2.4.0 will fail with your jdk.
However, these examples are stored in github under the akka project so you could clone from there and checkout an older version, which should work with your machine:
https://github.com/akka/akka/tree/v2.3.14/akka-samples/akka-sample-main-java
Your class is compiled for Java 8 (that's what version 52 means). You need to recompile (or find a precompiled version) for Java 7.

java.lang.UnsupportedClassVersionError when following tutorial

I'm trying to use Play! but I always get an error when trying to run a project: [error] java.lang.UnsupportedClassVersionError: com/typesafe/config/ConfigException : Unsupported major.minor version 52.0
When I do java -version or javac -version, it confirms I'm using Java 8 by outputting 1.8.0_45. I don't understand why this error happens, the docs says I NEED java 8 for the latest Play! version, the project has a dependency to Play! 2.4.2.
I followed the documentation: installed activator, added it to the path, generated a new project form the template 'java-play-intro' but when i type activator in my project directory, I always get the error above. I tried to use the update-alternative command to use java 6 and then 7 but the error is exactly the same.
BUT when I use activator ui it works fine !
How is this possible? Am I always supposed to use the UI?
Most probably the script you are starting, uses the JAVA_HOME environment variable and not the JDK binaries that can be found on your PATH.

UnsupportedClassVersionError when running Ant from eclipse

I'm trying to run an ant script from eclipse but it fails with the following message:
BUILD FAILED
project_path/build.xml:5:
java.lang.UnsupportedClassVersionError: com/sun/tools/javac/Main :
Unsupported major.minor version 51.0
However, when I run this from command line (./ant) it runs as expected.
Environment info:
OS: Linux Mint 64
Eclipse: Juno (4.2.1)
JDK: Oracle 1.7.0_11
Ant (command line): 1.8.2
I've also set the "Ant Home" (within eclipse settings) to be the same as the one I use from command line.
I've searched a lot on this issue but I can't seem to find anything that helped, I can try to uninstall all java (jdk/jre) I currently have installed, and then reinstall java 7, but I prefer not to take this route.
Any ideas?
Thanks!
UnsupportedClassVersionError: com/sun/tools/javac/Main : Unsupported major.minor version 51.0
This suggests there's some mix up between versions - Ant is trying to run the Java 7 javac on a Java 6 JVM. Have a look at your project properties, builders, Ant Builder, and check the classpath section. On my Eclipse with a newly-created Ant Builder I have the tools.jar from my 1.7 JDK listed under user entries -> additional tasks and support. If you have the same, but your Eclipse is itself running on Java 6 then it won't work. You can find out which Java Eclipse itself is running on via the "about Eclipse" box under installation details -> configuration. This may not be the same as the version of Java that your project is configured to use.
Another thing that might fix it is to go to the JRE tab in the ant builder settings and tell it to run in a separate JRE rather than running within the Eclipse process.
Your Eclipse ant task is trying to run the Java7 JDK compiler using a pre-Java7 JDK/JRE. Make sure you use a Java7 JRE to run Eclipse.
generally if you compile Java program in Java 1.7 it will create class file with major version 51.0 and if you run that on lower java version you will get
java.lang.unsupportedclassversionerror unsupported major.minor version 51.0
check this post for more details on the same

Categories

Resources