0

I have an odd one for you. I have a simple .jar installer program that I wrote in Eclipse on my MacBook Pro, running OS X 10.6.8. When I run the program in Windows 7, Vista and XP; works like a dream. However, when I try and run it in OS X 10.6.8, the program will execute like it should, however when it completes its execution I get the "Bad version number in .class file" error message. I ran "java -version" from the terminal and got

java version "1.6.0_24" Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326) Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)

I also confirmed that Eclipse's compiler is using Java 1.6 for everything. As I have scoured the forums it looks like this error prevents the running of the program; but I have yet to see anything about the error showing up after the program has already run.

jonsca
  • 10,218
  • 26
  • 54
  • 62
  • You may want to look at this question to confirm what version was generated: [how to check the jdk version used to compile a .class file](http://stackoverflow.com/questions/1096148/how-to-check-the-jdk-version-used-to-compile-a-class-file) (remember, a JAR file is merely a zip file with a different extension, so you should be able to unzip the class files from it) – Adam Paynter Jun 26 '11 at 09:16
  • Hi Adam, thanks for the tip. I was unable to check the versions of the classes within the jar file. How would I go about unzipping the class files from the jar file? Thanks! – Barrett Avery Jun 26 '11 at 23:59

2 Answers2

2

Bad version number in .class file means the program was compiled in a newer version of JDK and you are attempting to run it in an older version of JVM.

E.G. you compiled using java 5.0 and are attempting to run using java 1.2.

Dennis
  • 3,962
  • 7
  • 26
  • 44
  • Yeah, I read that. However when I checked what my machine was using for what version of Java it was running, it was the same as what I compiled it in. Do you know much about Eclipse? Could it be there is some hidden setting in there that would be causing this? I checked that it was indeed compiled using java 1.6. Any thoughts? – Barrett Avery Jun 26 '11 at 06:47
  • Hmm that is odd, have you tried re-installing JRE? Also you might want to check project properties, here is image: http://i926.photobucket.com/albums/ad105/onelin/eclipse_project_java_compiler_setti.png – Dennis Jun 26 '11 at 06:55
  • There was a Java 5.0 and Java 1.2, perhaps that is what you meant. ;) – Peter Lawrey Jun 26 '11 at 17:39
  • I checked the project properties and they were all set to JRE 1.6, which is what OS X 10.6.8 has as the default. Thanks for the screenshot, was helpful : ). Any other ideas? – Barrett Avery Jun 26 '11 at 23:50
0

Do you have some dependencies in the project? Like external .jar files (either as separate .jars or classes repacked to your jar)? They could be compiled with newer version of java (1.7 maybe?) or a bit newer version of 1.6 (on Windows there is 1.6.26 now - Mac version usually lags a bit).

Jarek Potiuk
  • 19,317
  • 2
  • 60
  • 61
  • The jar file I am compiling is only one .java file, 1 manifest file and one icon file that are all within the same Eclipse project src folder. Good to check on that though. Any other thoughts? Thanks, – Barrett Avery Jun 26 '11 at 23:48
  • Also, I am running Java 1.6.0_24 which is the most recent version for OS X. Thanks! – Barrett Avery Jun 27 '11 at 00:00