aspose file tools*
The moose likes Beginning Java and the fly likes appletviewer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "appletviewer" Watch "appletviewer" New topic
Author

appletviewer

Fredrik Coulter
Greenhorn

Joined: Feb 07, 2011
Posts: 3
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?

Fred
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

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?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Fredrik Coulter
Greenhorn

Joined: Feb 07, 2011
Posts: 3
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.

Thanks,

Fred
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: appletviewer