File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Can't run demo applets - Bad major version # Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Can Watch "Can New topic
Author

Can't run demo applets - Bad major version #

Jeff Fisher
Greenhorn

Joined: Jun 14, 2002
Posts: 18
Hello,
I am currently unable to bring up any of the SDK demo applets on my PC's browser. I remember that I was able to do this when I first began to learn Java a couple of years ago. About a year ago I noticed that I needed to run appletviewer to see the demo applets, but that didn't bother me. Now, however, I have installed Tomcat and am trying to learn JSP. I can move from an HTML form to a JSP and back again, which indicates to me that Tomcat is working, but none of the Java code on the JSP works. I know this is not a JSP forum, but I supect that my problem with viewing applets in my browser is related.
I use Windows 98. One of the first things I tried was to reinstall Java. I currently have Java SDK version 1.4.2_02 installed. After reinstalling the SDK didn't work, I tried installing the same version of the JRE (alongside the JDK), even though it is my understanding that the functionality in the SDK is a superset of the JRE functionality. In Internet Explorer, under the Internet Options Advanced tab, I have all the options for Java checked, including "Use Java 2 v1.4.2_02 for <applet>."
When I try to run a demo applet in IE by clicking on the associated HTML file, I get a ClassNotFoundException that shows up in the Java Console (it looks like IE is trying to use the MSJVM - is evil Microsoft causing this problem?). However, when I try to use Netscape, I get a different error message: "ClassFormatError: Bad major version number." In both cases I can tell that I've clicked on the correct HTML file (the proper heading shows up, along with a link to "The source." Also, I've checked the HTML file using Notepad). Again, I can use appletviewer and the applets work just fine - the problem only occurs within a browser.
Can somebody help me with this?
Thanks very much, Jeff
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
What plug-in version of the JVM are you using with your browsers? It must be at least 1.4.2 if you want to run apps you compiled with the 1.4.2_02 JDK.
One quick thing you might try is recompiling with the -source flag which "provide[s] source compatibility with specified release."
Lets assume for example your Plug in uses the 1.3 JVM.
try
javac -source 1.3 ....
(where the dots are the rest of your normal compile statement.)


Rob
SCJP 1.4
Jeff Fisher
Greenhorn

Joined: Jun 14, 2002
Posts: 18
Hi, Rob. I get the same type of error message (java.lang.ClassFormatError) whether I use Netscape or Internet Explorer. I wasn't really aware of the issue of browser plug-ins before looking around in this forum.
In Netscape, when I choose menu option Help followed by About Plug-ins, it says that the "Java Virtual Machine for Netscape" is enabled. It lists file names and includes the heading "Java Plug-in 1.4.2_02 for Netscape Navigator (DLL Helper)." This plug-in must have been installed as part of the JDK installation process - I know I didn't install it myself.
I don't see a similar "About Plug-ins" menu option in IE, but when I view the Java console in IE it says "Microsoft (R) VM for Java (tm), 4.0 Release 4.79.0.2424." And under Tools, Internet Options, Advanced tab, a box is checked that says "Use Java 2 v1.4.2_02 for <applet> (requires restart)."
I did try to use the -source compiler directive for the "Blink" demo applet (javac -source 1.4 Blink.java). The compile went OK, and the Blink applet still works in appletviewer, but I still get the same error when I try to run the applet in either Netscape or IE.
My PC is about 5 years old, and it's been my experience that weird things can happen on obsolete computers. I'm thinking about buying a new PC, but everything else still seems to work, and I'm not sure I can blame this problem on my current machine.
I appreciate your time with this. Happy Holidays, Jeff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't run demo applets - Bad major version #