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 Applet not initializing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet not initializing" Watch "Applet not initializing" New topic
Author

Applet not initializing

Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
This is my first time writing a applet, and I'm getting an error that it is not initialized. I was pretty sure I did everything the book said to do, so I'm wondering if anyone could take a look at my code and see where I might have done something wrong. The CheckBoxApplet.java file does compile, but the applet does not initialize.
CheckBoxApplet.java

CheckBoxApplet.html

------------------
Thanks, Dianne


Thanks, Dianne
sabbir kazi
Ranch Hand

Joined: Feb 03, 2001
Posts: 62
Could you please send us the exact error message that is thrown in the "Applet Console" of the browser.
As a reminder, you have to put the applet in the same directory as the html (that contains the applet tag) resides.
Another cause may be the POLICY file.
Sabbir
Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
Yeah, I have the applet file and the html file in the same directory. Here is what the screen said:
[error]
C:\myjava\assignment2\problem1>javac CheckBoxApplet.java
C:\myjava\assignment2\problem1>appletViewer CheckBoxApplet.html
java.lang.ClassCastException: CheckBoxApplet
at sun.applet.AppletPanel.createApplet(AppletPanel.java:579)
at sun.applet.AppletPanel.runLoader(AppletPanel.java:515)
at sun.applet.AppletPanel.run(AppletPanel.java:293)
at java.lang.Thread.run(Thread.java:484)
C:\myjava\assignment2\problem1>
[/error]
The applet window itself says "Start: applet not initialized."
In the Browser it doesn't say anything, it's just a grey box.
Also, I don't know what you mean by Policy file.
------------------
Thanks, Dianne
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Dianne,
In order to create an applet you need to subclass 1 of 2 classes:
java.awt.Applet
or
javax.swing.JApplet
Which of these two have you subclassed?
Regards,
Manfred.
Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
What do you mean by subclass? I don't remember my teacher saying anything about a subclass.
------------------
Thanks, Dianne
peter johansson
Greenhorn

Joined: Oct 25, 2001
Posts: 9
In order to run a class as an applet it must be declared public(as you have done) also it must subclass java.applet.Applet(you could also use the JApplet).
regards,
/Peter
Originally posted by Dianne Calhoun:
[B]This is my first time writing a applet, and I'm getting an error that it is not initialized. I was pretty sure I did everything the book said to do, so I'm wondering if anyone could take a look at my code and see where I might have done something wrong. The CheckBoxApplet.java file does compile, but the applet does not initialize.
CheckBoxApplet.java

CheckBoxApplet.html

[/B]

sabbir kazi
Ranch Hand

Joined: Feb 03, 2001
Posts: 62
Hi Dianne,
Looks like you have created an app instead of Applet. You may run your app using the "java app_name" command.
Sabbir
Dianne Calhoun
Greenhorn

Joined: Sep 25, 2001
Posts: 29
Okay, I see now. I had to change the CheckBoxApplet extends JFrame to CheckBoxApplet extends JApplet. It works great now.
------------------
Thanks, Dianne
Michael Oates
Greenhorn

Joined: Jan 02, 2013
Posts: 1
I did what you said, and the applet still won't initialize. What am I doning wrong?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> What am I doning wrong?

to start, posting to an 11-year-old post, with a number of replies already,
cuts down the number of people that will see your post.

much better to start your own topic (use the same subject if you like),
then post the code you've tried and explain the problem, or the steps to recreate the problem,
and I'm sure you'll get an answer in a reasonably quick time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet not initializing
 
Similar Threads
TextAreaHandler
null pointer again!
A confused new user of Java that needs some help
A confused new user of Java that needs some help
Help i need help with borderlayout