wood burning stoves 2.0*
The moose likes Applets and the fly likes How to run  the applet from command line? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "How to run  the applet from command line?" Watch "How to run  the applet from command line?" New topic
Author

How to run the applet from command line?

Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
Does someone can give to me an advice how to run the Java applet from command line?
Thnaks
Senthamizh
Greenhorn

Joined: Nov 16, 2001
Posts: 18
Hi, Running Applet in Command Line is simple.
First, Embed the following code in the applet file as a multiline comment.
Ex: your applet class file name is SampleApplet.class
/*
<applet code="SampleApplet.class" CodeBase="" width=300 height=400></applet>
*/
in the Command Line,
c:>appletviewer SampleApplet.java
Mike Shn
Ranch Hand

Joined: May 26, 2001
Posts: 149
Where do I have to put the
/*
<applet code="SampleApplet.class" CodeBase="" width=300 height=400></applet>
*/
In the HTML document?
Martha Yeh
Greenhorn

Joined: Jan 31, 2001
Posts: 18
Where do I have to put the
/*
<applet code="SampleApplet.class" CodeBase="" width=300 height=400></applet>
*/
In the HTML document?

hello there,
/*
<html>
<applet code="SampleApplet.class" CodeBase="" width=300 height=400></applet>
</html>
*/
save this as "SampleApplet.html"
c:\>javac SampleApplet.java
c:\>appletviewer SampleApplet.html

martha
Abhinav Sharma
Greenhorn

Joined: Aug 08, 2001
Posts: 25
Hi mike,
Let me answer you in a very simple so that you can understand. First write a applet. Save it in .java. And then compile it from the command line with javac applet.java and then execute it with this command appletviewer applet.java. But i hope you are doing all this after seeting the class path. After setting the path you can use this. Suppose you have saved your file in c:/applets folder. Go to that folder in dos prompt like this
c:/applet> javac applet.java
enter and then
c:/applet> appletviewer applet.java
enter
I hope this helps you and type inside your java code either on top or on bottom.
/*<applet code=applet.java width=100 height=100>
</applet>*/
This recognizes the code as applet
abhinav
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run the applet from command line?