-3

I am trying to deploy my JSP and java files on the server. But when I try to access the jsp I get the error msg

 javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/usct/db/DBConnect : Unsupported major.minor version 51.0

I read a few posts and found out that this is due to difference in Java version on the two different platforms but I am using JAVA 1.7 on my server and my client when I do

java -version

in my jdk/bin it shows that the java version is 1.7.0_10 and

Java SE Runtime Environment (build 1.7.0_10-b18)

Can someone please help me with this issue?

Thank you

Nemin
  • 1,907
  • 6
  • 24
  • 37
  • 3
    possible duplicate of [Unsupported major.minor version 51.0](http://stackoverflow.com/questions/10382929/unsupported-major-minor-version-51-0) – Stephen C Aug 10 '13 at 08:04

4 Answers4

3

... but I am using JAVA 1.7 on my server and my client when I do ...

The most likely explanation is that you are actually using Java 1.6 or earlier ... despite what you think. In other words, when you run java -version from the command-line, you are getting a different Java installation to the one that is being used to run your web container.

(If you are on a Linux system, you should be able to tell which JVM is being used by running ps -efl and greping for "java" or similar. Alternatively, use the approach suggested by @dbf.)

It is worth noting that the version of Java on the client is not relevant. The exception is occurring on the server side.

Reference: How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version - explains the general problem and solution.

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

java.lang.UnsupportedClassVersionError error occurs due to higher JDK during compile time and lower JDK during runtime.

Java Version     Major Version

 Java 4               48.0 
 Java 5               49.0 
 Java 6               50.0 
 Java 7               51.0

So if you compile your Java source file with javac of JDK 1.7 it will create class files with major version 51.0 and if you run those class files with Java 1.6 it will throw java.lang.unsupportedclassversionerror unsupported major.minor version 51.0 error

Try Compiling with older JDK or Upgrade the JRE.

More more information visit.

Ankur Lathi
  • 7,636
  • 5
  • 37
  • 49
0

I believe com/usct/db/DBConnect is not a class provided by Java. And hence the reason of your error is not the version of jdk and jre on both your coding and execution environment. It seems the jar you used for the class DBConnect on your client and environment are of different java versions.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
0

Try to print System.getProperty("java.version") from your JSP to check what version is actually used by your server.

dbf
  • 6,399
  • 2
  • 38
  • 65