Sunday, December 18, 2011

1-Basic Java Commands:

Basic Java Commands:
If you lose control of your console running a java program you can press Ctrl-C to close your program. If you require more memory than Windows wants to provide for a high memory program you can run a java console program called myprogram (provided you have 1450m of Xmx and 256m Xms memory):
java -Xms256m -Xmx1450m myprogram
If you wish to determine which version of java you are running enter this at the console:
java -version
If you wish to compile a file called myfile.java at the console:
javac myfile.java
If you wish to run a console application called myfile from the command line:
java myfile
To see how to run an applet from the command line first make a no frills web page called lines5.html which has the following code:
<!DOCTYPE HTML><HTML><HEAD></HEAD><BODY>
<APPLET CODE="lines5.class" CODEBASE="." WIDTH=400 HEIGHT=300></APPLET>
</BODY></HTML>

Then make an applet called lines5.java with this code:
import java.awt.Graphics;
public class lines5 extends java.applet.Applet
{
 public void paint(Graphics screen)
 {
   int i,x=0;
   int y=0;
   for(x=0;x<350;x=x+1)
   {
      y=4*x+(x*x*x);     screen.drawRoundRect(15,15,200,250,70,30);
   }
 }
}
To run the above applet and web page from the command line enter:

c:\>appletviewer lines5.html
(Back) 

0 comments:

Post a Comment