Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to run the applet from command line?

 
Mike Shn
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does someone can give to me an advice how to run the Java applet from command line?
Thnaks
 
Senthamizh
Greenhorn
Posts: 18
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do I have to put the
/*
<applet code="SampleApplet.class" CodeBase="" width=300 height=400></applet>
*/
In the HTML document?
 
Martha Yeh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic