13

When I run start.jar I get the following error:

 Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/
 jetty/start/Main : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(Unknown Source)
    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$000(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)
 Could not find the main class: org.eclipse.jetty.start.Main. Program will exit.

According to the Jetty documentation (http://www.eclipse.org/jetty/documentation/current/quickstart-running-jetty.html), all I need to do is download the zip, extract, and run start.jar. Google doesn't seem to provide me with any people having similar issues.

Thanks, Sam

Samuel Smith
  • 340
  • 4
  • 8
  • 21

6 Answers6

11

Take a look on the following discussion and specifically on the most popular answer.

Shortly you have a problem of class version incompatibility. Your jetty is compiled with compiler of java 7 while you are trying to run it with JVM of previous version. The solution is: go forward to Java 7: upgrade your JDK and configure eclipse to use java 7 and start enjoying the new features.

Community
  • 1
  • 1
AlexR
  • 114,158
  • 16
  • 130
  • 208
  • 1
    Ah, thanks. Unfortunately, I don't have the permissions to upgrade the JDK, so I'll take Jetty back to an earlier version, instead. – Samuel Smith May 22 '13 at 07:33
  • 3
    How to find the proper earlier version? unjar start.jar and look in META-INF/MANIFEST.MF for Build-Jdk but even jetty version 7.6.14 was compiled with 1.7.0_25 – ericslaw Mar 11 '14 at 21:58
7

This could happen when you have some code compiled using higher JDK, try to check the JDKs used to compile your code.

Besides according to the documetnation Jetty 9 needs JVM 1.7.

Further links:

Community
  • 1
  • 1
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130
3

The newest release of Jetty needs Version 1.7 of the JVM. Update your JVM or use an older version of Jetty (not recommended).

You can see the Jetty-versions here: http://www.eclipse.org/jetty/documentation/9.0.2.v20130417/what-jetty-version.html#d0e75

looper
  • 1,929
  • 23
  • 42
  • This is half of the 'use an older jetty version' solution. It implies that Jetty8.x built from source using existing JRE might work. – ericslaw Mar 11 '14 at 22:02
2

java.lang.UnsupportedClassVersionError happens because of a higher JDK during compile time and lower JRE during runtime.

So upgred your JRE to the version of compiled time version of JDK.

Alpesh Gediya
  • 3,706
  • 1
  • 25
  • 38
0

The Java compiler is an advanced version, and the virtual machine is not. Make it uniform either by upgrading your JVM or downgrading your compiler (JDK). I recommend the second option. Gook luck !!!!

mani_nz
  • 4,522
  • 3
  • 28
  • 37
0

This can also happend if you are configuring for example Jetty 8.1 server, but your Jetty installation directory is higher than that, for example 9.1.

So download proper Jetty installation, in Eclipse go to Windows -> Preferences -> Servers -> Jetty -> Edit -> browse to your newly downloaded installation directory.

Dino Velić
  • 888
  • 11
  • 24