wood burning stoves 2.0*
The moose likes Applets and the fly likes how to run applets classes ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "how to run applets classes ?" Watch "how to run applets classes ?" New topic
Author

how to run applets classes ?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Hi:
i have a class which extends applets.
in which I set the layouts, add components etc
i was wondering how to run the applet class ...
i tried to run it like a regular java application,
but it din't do much.
i also tried it with a html file like
"appletviewer Test.html"
In the html file I have

ToolStatus.java (RHE, p 277) is my file name ofcourse.
Could somebody help me with...what I am missing?
Thanks.
- satya
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Satya, This nature of your qstn is suitable more for Applets forum. So we will discuss it there.
regds
maha anna
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

Maha:
First, I did not know about this Applet forum.
Second, I was doing it wrong. In my code, I created
a new Applet in the constructor and added my components
to this Applet. So, the Applet created in the main()
method was not showing my components.
I corrected it and it works.
Please close the thread. Sorry, my mistake.
Thanks.
- satya
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Satya,
It is very simple.
1. Compile the ToolStatus.java code. Keep the ToolStatus.class file ready.
2. create a <b>test.html</b> file like foll.
< html >
< applet code="ToolStatus.class" width=100 height=100 >
< /applet >
< /html >
3. In the Dos command prompt type <b>appletviewer test.html </b>
4. You will see the applet. (I purposly included space bet html tags in order to avoid this forum s/w from interpreting)
I tested with a simple helloworld.class . Appletviwer shows fine.
regds
maha anna

[This message has been edited by maha anna (edited April 29, 2000).]
[This message has been edited by maha anna (edited April 29, 2000).]
Suma Narayan
Ranch Hand

Joined: Apr 03, 2000
Posts: 136
Hi Satya5,
An applet will not run the same way as other java programs. There are two ways you can run them.
1. Using appletviewer.(the way you did)
2. By browsing the html file.
The html file should look something like this.
<html>
<head>
<title> Sample Applet</title>
</head>
<body>
<applet code = TryApplet.class width =300 height=200>
</applet>
</body>
</html>
The html file which you have created does not have the keyword
applet before the word code and hence is not working. You must be probably getting this error "No Applets were started. Make sure the input contains an <applet> tag."
This should work.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to run applets classes ?
 
Similar Threads
Applet in HTML
HelloWorld not working
html and jar file?
Start: Applet not initialized
Applets fail to load in a browser