Java Reference
In-Depth Information
(b) Type in this command in the terminal window:
jar -umf x.mf app.jar
The “u” stands for
update
, the “m” for
manifest
, and the “f” for
file
. Since the
“m” precedes the “f”, the manifest file name,
x.mf
, precedes the file name,
app.jar
. This command inserts into jar file
app.jar
the fact that method
main
appears in class
CMain
.
You can insert the classes and the main-class manifest in one step using:
jar -cmf x.mf app.jar *.class
You can now email file
app.jar
to anyone, and they can run it on their com-
puter, whether it is a Unix, Macintosh, or Windows system, as long as their sys-
tem runs java. To execute the program, type this (include the extension
.jar
):
java -jar app.jar
In some systems, you will be able to run the program by double-clicking the file.
If you want to see what is in jar file
app.jar
, then type this:
jar tvf app.jar
You can find out more about the jar command by typing the following and hit-
ting the enter/return key:
jar app.jar
Variable path
If you cannot execute any of the commands
java
,
javac
,
jar
, and
javadoc
,
then you probably have not set your
path
correctly. We explain this for Windows
2000; older windows systems are similar.
Your system contains a variable that lists directories that have executable
files in them. Type
path
in a command-line window. A line will be printed that
contains path names separated by semicolons. For example, one path name may
be:
C:\WINNT\system32
There should be a path that looks something like this:
C :\j2sdk1.4.1_02\bin
This is a directory called
bin
inside the directory where you installed the sdk. It
may be different on your computer. If such a path is not there, you have to add
it. Bring up the help in your Windows system, open the index, and look for
path
.
There, you will find instructions on appending another directory to variable
path
. It may be something like the following, but read the instructions:
path %path%;C:\j2sdk1.4.1_02\bin
Search WWH ::
Custom Search