aspose file tools*
The moose likes Beginning Java and the fly likes Bad Version Number in .class file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Bad Version Number in .class file" Watch "Bad Version Number in .class file" New topic
Author

Bad Version Number in .class file

Jim Shaw
Greenhorn

Joined: Jan 25, 2008
Posts: 9
I just purchased "Head First Java" (2nd ed.), and am trying to do the first exercise after having downloaded the SDK.

I wanted the Java 2 Standard Edition SDK, as specified in the book, but I couldn't find that on the java.sun website (after all, the book was published in 2005) so I got Enterprise Edition 5 SDK instead.

I successfully compiled my first primitive program, which just spits out some text. Unfortunately, when I executed the program I got the following error:
"Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file at ...."

Here is my source code:
import java.awt.*;
import java.awt.event.*;
class Party {
public void buildInvite() {
Frame f = new Frame();
Label l = new Label("Party at Tim's");
Button b = new Button("You Bet");
Button c = new Button("Shoot me");
Panel p = new Panel();
p.add(l);
} // more code here...
}

What direction can you give me to correct this error?

Thanks
[ January 25, 2008: Message edited by: Jim Shaw ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

Standard Edition (SE) is basic, "core" Java, and that's what you want for starting out. Enterprise Edition (EE) is an advanced edition for things like server programming.

Sun has some confusing approaches to naming and numbering. The language has been called "Java 2" since version 1.2 came out. Subsequent versions (1.3 through 1.6) are all considered "Java 2." To confuse things further, Java SE 6 is the same as Java SE 1.6, and this is the current version of the Java 2 Platform.

From Sun's Java SE download page, you can use JDK 6 Update 4, which is the current version of the "Java 2 Standard Edition SDK." This should work fine with the 2nd edition of Head First Java. After downloading, be sure to follow the installation instructions (especially the step about updating the PATH variable).

"Bad version number in .class file" usually means that the class was compiled using a Java Development Kit (JDK) that's newer than the Java Runtime Environment (JRE) trying to run it. Once you've installed JDK 6 (which includes the JRE), I think you'll be okay.

NOTE: The code you're working with is not complete. If you take another look at the book, you should see a note that explains the code is just a snippet to illustrate an overall concept, and it's not meant to be run as written. The "real" coding starts in the next few pages.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad Version Number in .class file