How to run java applet program using cmd
Hi friends, recently I have started learning the Java Applet, I have completed chapter first. There are some of the few steps were given to execute the Applet using the command prompt, however I am not able to understand the concept that were written on that notes. SO I just want to know how I can execute the java Applet program using cmd. I have try various steps to make it happen but still not able to clear with the steps for running the Java Applet using cmd. So if you guys have any of the information or any of the solution or ideas then please let me know.
Re: How to run java applet program using cmd
According to my information you have to first compile your source code that you have created, so for that you just have to make use of the cmd and then go to the proper directory where you have save your source code. And then compile the source code with the command
javac yourcode.java // yourcode is the name of the java class that you have created.
After compiling your source code, you have to make use of the appletviewer to view your applet page.
appletviewer yourcode.java // yourcode is the name of the java class that you have created.
Re: How to run java applet program using cmd
To run any of the Applet program, you have to follow this simple steps:
- The first thing you have to do is to save the applet file and the html file in the same folder.
- Then you have to compile the applet program using command prompt ‘javac ClassName.java’.
- And finally type ‘appletviewer YourClassName.html’
- Your applets program executes.
Re: How to run java applet program using cmd
Try this simple Applet program, may it will help you out
First create a simple Applet code and save it as Abc.java
Quote:
import java.applet.*;
import java.awt.*;
public class Abc extends Applet
{
String str;
public void init()
{
str = "Hi Dude!!! This works…";
}
public void paint(Graphics g)
{
g.drawString(str, 50,50);
}
}
And then create one html page and save it as abc.html:
Quote:
<HTML>
<BODY>
<applet code="Abc",height="400" width="400">
</applet>
</BODY>
</HTML>
Make sure to place this both file in the same folder.
Open cmd and compile the Applet code using javac.
And then make use of appletviewer to execute your applet program