• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown


Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

appletviewer simpleApplet.html

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.

What am I doing wrong?

Posts: 21972
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Could you please UseCodeTags next time? I've added them for you this time.

One problem you have is you forgot to call super.paint(g) as first line of your paint method. That's not causing this error, but it should still be fixed.

This error seems to be a problem in the .class file. Have you tried recompiling and re-uploading?
Fredrik Coulter
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Recompiling it worked fine.

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.


Posts: 69843
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic