Saturday, August 31, 2002


just in case you didn't know...
rm -r
is not your friend. Anyone know how to redefine cygwin so it just moves stuff to the Recycling Bin? Until I get CVS working I'm going to be REALLY careful.
7:28:42 PM    

expanding jar files

jar -xf foo.jar



creating jar files

You can create the hw0.jar file by using the following command:

prompt> jar cf hw0.jar Hello.java Exclamation.java

The "jar" program is a utility that creates and unpacks Java archive files. The "c" option indicates that we want to create a new Java archive. The "f" option specifies that we want the Java archive to be created into the file named "hw0.jar". The remaining arguments on the command line give the names of the source files to put into the archive.

One very common error is to do the following: Try typing in the following command (but don't do it if you haven't already created hw0.jar using the command above first):

prompt> jar cf Hello.java Exclamation.java

What has happened here is that the Java archive file has been created and put into a file named Hello.java. This effectively has deleted your Hello.java file!. As you can see, the first parameter to the jar command is the name of the jar file, and the remaining parameters are the files to put in it. You must be very very very careful when creating your Java archive file, because if you accidentally delete one of your java files, it's impossible to get it back.

Luckily, in this case we have already created a good archive in hw0.jar, so we can restore our Hello.java file simply by unpacking the archive:

prompt> jar xf hw0.jar

 

More Detailed notes on using JAR


6:13:08 PM