What Version of Maven is Compatible with Java 6? - java

I have to work in an older project that requires java 6 to run, as there are references to depreciated sun classes that have been removed in future versions. As part of the process, I changed my jdk from 8 in my system path to point to java 6 jdk. After doing so I get:
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:254)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(Launcher.java:144)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:266)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
This is is similar to Maven Installation OSX Error Unsupported major.minor version 51.0 and Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0) however I'm not looking to upgrade, I'm looking to find a version of maven that is compatible with java 6. Any ideas on which version is compatible and where I can download/install it from for mac?

According to the Maven release history page, the last Maven version that works with JDK1.6 is 3.2.5.
Note that it's better to keep using the newer Maven version (and keep Java 8 as the default in the system path), and tell Maven that the project it's building should compile with source set to 1.6 - see source and target documentation for more info. Reverting to an old Maven will remove the bug fixes / enhancements of the newer versions.

If you have the problem you need to build with JDK 6 but you would like run Maven with JDK 7 (cause you like to use Maven 3.3+) you should consider using toolchain which makes this independent from each other.

Related

Build Java 6 Project with Maven 3.0 and Jenkins 2.1XX : Unsupported major.minor version 51.0

I am new to Jenkins and I am currently setting up some automated builds on a local server we have. Half of the projects are using JDK 8 with Maven 3.3+ and works pretty fine.
However, We have other older projects that we still need to build that requires JDK 6 and Maven 3.0 (it should work with Maven 3.2 too). Using Eclipse IDE, the project compile successfuly but when run by a Jenkins Maven job, it returns this error :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jvnet/hudson/maven3/agent/Maven3Main : Unsupported major.minor version 51.0
I checked that Jenkins uses the right JDK and Maven version which are mentionned in the trace :
$ /usr/lib/jvm/java-6-oracle/bin/java -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.12-alpha-1.jar:/usr/share/maven-3.0.5/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /usr/share/maven-3.0.5 /var/cache/jenkins/war/WEB-INF/lib/remoting-3.17.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.12-alpha-1.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.12-alpha-1.jar 45589
I've read some thread about Jenkins no longer being able to build Java projects with JDK older than 8 (I've only searched about Maven though).
It makes sense looking at the console output, Jenkins looks like he tries to retrieve some of its own files using the job's specified JDK (6), but I don't really get why he needs to do so ? Is it related to Jenkins' Core ?
Upgrading the projects to Java 8 isn't an option, nor downgrading Jenkins.
Is there a workaround in order to build a Java 6 project with Jenkins using Maven ?
I've tried using -Dmaven.compiler.source=1.6 -Dmaven.compiler.target=1.6 in the MAVEN_OPTS but doesn't work either.
There's probably something I missed as I'm new to Jenkins but couldn't find out after some hours. I'm not against a helping hand, thanks.
Here is the end of the console output :
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jvnet/hudson/maven3/agent/Maven3Main : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.jvnet.hudson.maven3.agent.Maven3Main. Program will exit.
ERROR: Failed to launch Maven. Exit code = 1
Finished: FAILURE

Unsupported ClassVersion Error when deploying jira

I am trying to run jira application on my local machine with atlas-run and atlas-debug command. But i have a build failure here.
[ERROR] Failed to execute goal com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:6.2.1:run (default-cli) on project ccd_jirautils: Execution de
fault-cli of goal com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:6.2.1:run failed: Unable to load the mojo 'run' in the plugin 'com.atlassia
n.maven.plugins:maven-amps-dispatcher-plugin:6.2.1' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupE
xception: com/atlassian/maven/plugins/ampsdispatcher/AmpsDispatcherRunMojo : Unsupported major.minor version 52.0
I tried to run the same on Linux machine i am able to get the success build with the jre 1.7 and atlassian_sdk version 5.0.3. when i am trying to run the same on Windows platform i get the above error. I also tried with jre 1.8 which is a bigtime failure jira refuse to start. so please I need your help here. can you please suggest me what might be the solution for this?
Caused by: java.lang.UnsupportedClassVersionError: com/atlassian/maven/plugins/ampsdispatcher/AmpsDispatcherRunMojo : Unsupported major.minor version
52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
at org.eclipse.sisu.space.URLClassSpace.loadClass(URLClassSpace.java:107)
... 41 more
Following are the major versions of JRE the class file is compatible with
Java SE 9 = 53
Java SE 8 = 52
Java SE 7 = 51
Check what version of JAVA does your MAVEN is using mvn -version. You should be using jre 1.7
You didn't mention the Jira version you're running, but the error, as mentioned by ravthiru comes from a Java version mismatch. That is you have to use Java 8 for this to work, at least if you stick to the atlas-run and atlas-debug scripts, which use the mentioned com.atlassian.maven.plugins:maven-amps-dispatcher-plugin:6.2.1
which is a bit odd, as that one is included in the plugin-sdk 6.2.2, maybe you updated the sdk? Would you mind having a look inside atlas-run and double check it's 5.0.3?
That plugin was compiled using Java 8, so you either have to do so too or use an older version of the atlassian-plugin-sdk, which was compiled using Java 7. The 5.x versions should work.
Regarding the failure of running Jira with Java 8: Which version are you running, and what errors does it log?

Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file in Jenkins

I am using Jenkins ver. 1.565.11.1 (Jenkins Enterprise by CloudBees 14.05) and have JDK 1.5,1.5.0.22,1.6,1.7 all are installed and using different versions for different projects.
My question is I compiled one project with JDK 1.7 by mistake but I have to compile it using jdk 1.5 but not able to do it. Getting below error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:389)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:242)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227)
at jenkins.maven3.agent.Maven31Main.main(Maven31Main.java:138)
at jenkins.maven3.agent.Maven31Main.main(Maven31Main.java:67)
ERROR: Failed to parse POMs
java.io.EOFException: unexpected stream termination
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:331)
at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:280)
at hudson.slaves.Channels.forProcess(Channels.java:114)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:280)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:755)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1706)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:232)
Finished: FAILURE
Maven 3.2 requires at least jdk 1.6 for execution.
If you want to use maven 3.2 (or newer) and compile code using the 1.5 jdk, you can look at using toolchains.

what is minimum version of jre to use java2word api

I am using API java2word-3.1.jar to create doc file.
it is working good in JRE 1.5+ version.
but I want to use it in JRE1.4.
could you please tell me any solution.
currently getting below error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: **word/api/interfaces/IDocument (Unsupported major.minor version 50.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)**
thanks and regards
Shankar
Either recompile the package yourself, if it will compile under 1.4, or else upgrade your Java to something that hasn't been unsupported since October 30th, 2008.
what is minimum version of jre to use java2word api
I don't know why you're asking that, when you've already established conclusively that it's 1.5.

Jar File is running in my computer but not Running in another computer [duplicate]

This question already has answers here:
How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version
(51 answers)
Closed 8 years ago.
I created a jar file in my laptop and it runs fine in my computer without trouble but when i use the same in my friend's laptop it shows and exception and the file does not run. But it's still good with my laptop. What's the reason?
name of jar =BlueServer.jar
it has only one class.
classname=Server.java
one external library is used name=Bluecove.jar which is used for accessing bluetooth from java.
Ide used=Eclipse
used Eclipse for creating jar,already checked the option "Pacakage required libraries into generated jar"
This Error came while i try to run that same jar in another computer....
java -jar BlueServer.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: Server : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
It is a problem with the version of the used JRE. See this post for details.
Try
java --version
on both machines.
This error indicates, that your file is not executable with the installed JRE version.
See How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version for more info about that.
java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JDK during runtime. Make sure the jdk version installed in your laptop is equal or higher than your friend's.

Categories

Resources