0

I am trying to run a java class file from the command prompt and keep getting this 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:620)
                     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14)
                     at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
                     at java.netURLClassLoader.acess$100(URLClassloader.java:56)
                     at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
                     at java.security.AccessController.doPrivileged(Native Method)
                     at java.ner.URLClassLoader.findClass(URLCLassLoader.java:306)
                     at sun.misc.Launcher$AppClassLaoder.loadClass(Launcher.java:268)
                     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)                                                                                                                                                 

Sorry for typing it out don't have the reputation to post pictures. I am trying to run a agent for a tictactoe app using jgrasp 1.8.4 and jdk1.5.0_08. This is for a my AI class so have to use these version of jgrasp and jdk.

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366
cdbean04
  • 57
  • 1
  • 8
  • The version of Java you compiled the program with is greater then the version you are running it with...or at least not compatiable – MadProgrammer Jan 30 '15 at 03:28

1 Answers1

1

Issue is that you are using different java version for compilation and running the code. Keep them same and it should work.

Lokesh
  • 7,810
  • 6
  • 48
  • 78
  • Any idea how to check which version Im using for compilation and which for running, Im new to working with java. – cdbean04 Jan 30 '15 at 15:20
  • Version used to compile java class can be checked using command "javap -verbose MyClass | findstr "major". In order to check java version used to run java class, just type "java -version" at command prompt. – Lokesh Jan 30 '15 at 18:55
  • Check this : http://stackoverflow.com/questions/1096148/how-to-check-the-jdk-version-used-to-compile-a-class-file – Lokesh Jan 30 '15 at 18:55