Thursday, September 25, 2008

100 making a .jar file

Here's the lab from September 23 that included making a .jar file to run from the command line. It's slightly changed. As far as I know, it worked OK, but student S.B. kindly pointed out a couple of things that I did not know.

First, if the manifest file doesn't have a newline (a.k.a. return) at the end of a line, it won't be read by the system.

Second, with Java 6 or later, you can specify an entry point, that is, class with a main( ) method, for your program from the jar command line. Suppose thatthe following: you are combining all the .class files in a directory into your .jar, your application will be called MyApp, and file ReallyMain.java contains the main( ) method that you want to use. You can say this:

   jar cfe MyApp.jar ReallyMain *.class

Whew. Read all you could want to know about it here, one little page of Sun's mega-tutorial on all things Java.

No comments: