MLS
MLS

Reputation: 895

java version difference in using pdfview library matters?

I am trying to run this example but it is giving me "Bad version number in .class file..." error. i'm using jdk version 1.6 and example asks to use jdk 1.5. java should support downward compatibility. how can i run the example with jdk 1.6?

Upvotes: 1

Views: 118

Answers (2)

Stephen C
Stephen C

Reputation: 718788

A "Bad version number in .class file..." error occurs when you try to run a class file with a new version number on an older JVM. (And even then, not in all cases)

Running a class file with an old version number on a newer JVM should work.


You can check the version number of a class file using javap -v <full-class-name>. The versions are:

major    minor       Java
45       3           1.0
45       3           1.1
46       0           1.2
47       0           1.3
48       0           1.4
49       0           1.5
50       0           1.6

and I think ...

51       0           1.7

Upvotes: 1

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81684

There's a subtle trap here that many new folks fall into. Sometimes -- often, actually -- you may have a copy of java.exe from an older JDK installed on your machine, appearing early in your path, that you don't know about. You can get into the situation where you compile classes with your shiny new JDK 1.6 compiler, and then try to run them with the old java.exe, and get the error mentioned here. If that old java.exe's location is earlier on your path than the JDK bin dir, then you'll find the compiler from the command line, but not the right version of java.exe itself.

The extra java.exe was often installed by an old installer for the Java Plug-In -- the thing that lets you run applets in your web browser. The rogue java.exe is likely in your WINDOWS directory, or some variant (this is a peculiarly Windows-centric problem).

If you've installed JDK 1.6 including the Java plugin, then you can simply delete the copy of java.exe in your WINDOWS directory. If you don't want to do that, you should change your path so that the JDK's bin directory is before WINDOWS.

Upvotes: 1

Related Questions