Java Reference
In-Depth Information
237 Sat Jun 12 16:51:48 EDT 2004 mypack/TestA.class
111 Sat Jun 12 16:51:12 EDT 2004 mypack/TestA.java
237 Sat Jun 12 16:51:48 EDT 2004 mypack/TestB.class
110 Sat Jun 12 16:51:26 EDT 2004 mypack/TestB.java
Note that the files are listed along with their directory paths.
5.6.1 Applet in a JAR
We can use an applet tag like the following that includes the archive attribute
to indicate the location of a JAR file containing the applet code. The JVM in the
browser looks in this JAR file for TestABCApplet.class and the required
packages.
< applet
code =" TestABCApplet.class "
archive =" TestABCApplet.jar "
width =" 150 " height =" 64 ">
</applet>
5.6.2 Application in a JAR
Yo u can also pack the classes for an application into a JAR and then run the
application directly from the JAR file as long as you include a proper man-
ifest file in the JAR. For example, if you placed the manifest and class files
for the application MyApp into MyApp.jar , then you would run the program
with
c: \ > java -jar MyApp.jar
To indicate which of the class files holds the main() method, the JAR files needs
to include a short manifest file with the text line
Main-Class: MyApp
An optional approach to use, especially when you need to access classes in several
JAR files, is to use the CLASSPATH option indicated by “-classpath or
“-cp . (See more about CLASSPATH in Section 5.7.) For example,
c: \ > java -cp MyApp.jar MyApp
or in the case of several additional JAR files
c: \ > java -cp MyApp.jar;MyHelp.jar;MyUtilities.jar MyApp
Search WWH ::




Custom Search