I am going through Java Language Basics, downloaded from the Oracle website. I've installed the latest version of NetBeans and Java (6.9.1). On lesson 3, I am given the following instructions:
Application to Applet The following code is the applet equivalent to the LessonTwoB application from Lesson 2. The figure below shows how the running applet looks. The structure and elements of the applet code are discussed after the section on how to run the applet just below.
The SimpleApplet class is declared public so the program that runs the applet (a browser or appletviewer), which is not local to the program can access it.
Run the Applet
To see the applet in action, you need an HTML file with the Applet tag as follows:
The easiest way to run the applet is with appletviewer shown below where simpleApplet.html is a file that contains the above HTML code:
The java code is in both a text file names SimpleApplet.java and in SimpleApplet.class. (Actually, I tried it both ways.) The html code is as stated. I've set up the path variable to include the bin directory.
When I run the appletviewer, I get the following error messages in the command window, and the applet opens and does nothing.
Learning both Java and NetBeans at the same time means that occassionally you do something stupid. (Or you don't do something you should have.)
I haven't done any serious programming in over fifteen years (since I got my B.S. in Computer Science in 1994), so I've got to get my programming head back on. In addition, the paradigm was just moving from procedural languages (Pascal, C) to object oriented just as I was graduating, so I've got to take a different view of it all. Heck, I've gone through one paradigm shift so far; what's one more?
Why am I relearning to program? I'm planning on starting a Masters in Management Information Systems next January. A prerequisiste to the program is either an expensive course from the university, or demonstration of programming ability. Therefore, time to get my chops back together.
I'll probably be posting more questions as I relearn how to program.
If you search for the Java .class file format, you find that it has a "magic number" very near its beginning. The "magic number" is 0xcafebabe, which is 3405691582 in decimal. So your error message suggests the file has somehow got corrupted.
I think you would be better off leaving NetBeans alone for the time being.Don't use Microsoft Notepad. Use a text editor, eg Notepad2, NotePad++, jEdit which I have used, and others recommend TextPad which I haven't used. Set it up to support automatic indentation, bracket matching, etc. Then learn to execute your programs from the command line.