Thank you for visiting Blazing Games

Using java

Of course, having a compiled program isn't much use if you can't run the program. Java applets and applications are run differently. In this section I will explain how to run a java application, and in the next section I will cover how applets can be run.

Java applications are ran through the java command. The basic format of the command is java class_to_run . For instance, to run the chapter 3 application we compiled in an earlier section, you would use the following command:
java com.blazinggames.jgp.chapter3.Chapter3

Now, as the classes may be in a different directory, you can use the -cp path or -classpath path options to change the base class directory. It is also possible to run certain jar files by using the format java -jar jarfile


Using appletviewer

As you should already know, applets are run on a browser. To run an applet you only need to open the html file with the applet tag in a browser window. Running a browser every time you want to test an applet, however, is not always practical. In fact, some browsers, such as IE, don't recognize changed classes so require that you shut down all browser windows and restart the browser to test changes. Thankfully, the JDK includes a tool for testing applets. This tool is called appletviewer.

Appletviewer does not run a class file directly, instead it requires an html page with an appropriate applet or object tag. The format for the command is appletviewer page.html . To test the applet we create in chapter 4 and compiled earlier, we would use the following command line:
appletviewer chapter4.html

Previous Chapter 2 Contents Page 6 of 7 Book Contents Next

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2004-2006 Blazing Games Inc. All Rights Reserved