Background, this application is running on Play! Framework 1.2.4 on a Mac OS X 10.5.8
The command I'm running: sudo play run
The exception thrown:
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:676)
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 java.lang.ClassLoader.loadClass(ClassLoader.java:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:375)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357)
at java.lang.Class.getConstructor0(Class.java:2671)
at java.lang.Class.newInstance0(Class.java:321)
at java.lang.Class.newInstance(Class.java:303)
at play.plugins.PluginCollection.loadPlugins(PluginCollection.java:158)
at play.Play.init(Play.java:294)
at play.server.Server.main(Server.java:158)
The application.conf for the application and all dependent modules are set to java.source=1.6
sudo $JAVA_HOME/bin/java -version yields java version "1.6.0_26"
I've even pointed /System/Java/Home to the 1.6 installation.
What else could be causing this?
Which Java version(s) do you have in your PATH? We got a similar issue (not with Play, though) in which all the settings of the application seemed to point to 1.6 but the PATH had a reference to 1.5 that was loaded first due to its position inside the PATH string.
Check your PATH. And, I'm not a Mac user, but it's necessary to use sudo? In Ubuntu I run Play without. If possible, this may help to reduce unexpected conflicts due to root user paths and configuration.
Related
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
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.
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.
I am trying to run an HelloWorld kind of program for Scala , in Intellij.
My code is:
package helloscala
object HelloScala { def main(args: Array[String]) {
Console.println("Hello, world!"); } }
I am clueless about the error , that is prompted by the INtellij IDE.
JDK is JDK5
Error is:
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
java.lang.ClassLoader.loadClass(ClassLoader.java:307) at
sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at
java.lang.ClassLoader.loadClass(ClassLoader.java:252) at
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Exception in thread "main"
Any input would be great.
Scala 2.10 doesn't support Java 5.
Software Requirements:
The Scala software distribution can be installed on any Unix-like or Windows system. It requires the Java runtime version 1.6 or later.
Use JDK 7 + sbt-idea plugin.
SBT is the preferred build tool
I recommend my project skeleton for setting it all up. Intllij + SBT (+eclipse if you so want to)
I'm trying to develop a java3d application, i try everything, i just download the jogamp-platform because how i could read in many websites the java3d is obsolete and for mac os x you need this, i put them all in /System/Frameworks/Java/Extensions where are my .jar files in order to not add to the classpath in Eclipse but it still getting the same error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/opengl/AbstractGraphicsDevice
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:171)
at javax.media.j3d.Pipeline$1.run(Pipeline.java:143)
at java.security.AccessController.doPrivileged(Native Method)
at javax.media.j3d.Pipeline.createPipeline(Pipeline.java:138)
at javax.media.j3d.MasterControl.loadLibraries(MasterControl.java:926)
at javax.media.j3d.VirtualUniverse.<clinit>(VirtualUniverse.java:280)
at javax.media.j3d.Canvas3D.<clinit>(Canvas3D.java:3862)
at Apartado_a.<init>(Apartado_a.java:17)
at Apartado_a.main(Apartado_a.java:67)
Caused by: java.lang.ClassNotFoundException: javax.media.opengl.AbstractGraphicsDevice
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 10 more
These are the files inside extensions folder:
j3daudio.jar
j3dcore.jar
j3dutils.jar
joal-natives-macosx-universal.jar
jogl-all.jar
gluegen-rt.jar
gluegen-rt-natives-macosx-universal.jar
Regards!
Mac OS X comes pre-installed with Java 3D version 1.3. You can find these files in /System/Library/Java/Extensions. If you need to install Java 3D version 1.5 (and it sounds like you do), then you can use this installer: http://create.ife.no/vr/tools/j3d/java3d_1_5_2-macosx.pkg.zip
Don't use the /System/Frameworks/Java/Extensions folder for this.
Instead, include the relevant libraries in the lib/ folder of your application. Also, check which version of the JDK you are using. I believe there are some issues with Java3D running on the newer Apple-provided JVMs versus the older Oracle/Sun provided ones.