• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to run the applet from command line?

 
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
 
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?
 
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
 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic