3

I am getting the follwing error while running selenium testcase.

 java.lang.UnsupportedClassVersionError: Bad version number in .class file

I have checked all the versions of java in eclispse and they are correct.

Please it would be greatful if you can help me out.

oz123
  • 27,559
  • 27
  • 125
  • 187
sarayu
  • 31
  • 1
  • 1
  • 4
  • Some version is not correct. This could be a jar file, not the code you compiled. What class are you getting this for? – Thilo Sep 02 '11 at 09:52
  • I am trying to run the selenium testcase.I am using junit3 to run the test – sarayu Sep 02 '11 at 10:01

2 Answers2

9

UnsupportedClassVersionError occurs typically when you have .class (typically in .jar-file) that has been compiled with higher version of java than virtual machine trying to run it. For example you have a .class-file that is compiled with JDK 6 and you are trying to run it with 1.4 JVM.

Check your PATH variable and test java -version command etc. Also check this thread for couple typical issues that cause this problem.

Community
  • 1
  • 1
Ahe
  • 2,124
  • 3
  • 19
  • 29
1

This error is due to mismatch in your Java Versions. Follow the following steps

  • Type Regedit in run and navigate to HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
  • See the version number mentioned in the registry
  • Download the same version and place it in your computer
  • Set JAVA_HOME to the jdk directory in environment variables
  • Add %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin to the path variable

Now check again.

Anand
  • 693
  • 1
  • 8
  • 26