Assignments - How To Use Jars

CSU540 Computer Graphics - Fall 2005 - Prof. Futrelle

Updated 20 September 2005


Jar files are single files that contain (normally compressed) collections of files, directories, and their contents. They are convenient for transferring/exchanging entire projects as single files.

Here is a page at Sun with a variety of links to Jar information.

I created an extended example involving executable jars, classes in subdirectories, even jarring a jar file. It's accessible in this class mailing list archive item.

Examples

Creating the jar file named csu540f05SmithA1.jar
from the ShapesPaths directory and its files --

jar cvf csu540f05SmithA1.jar ShapesPaths

Viewing the contents of the file csu540f05SmithA1.jar --

jar tf csu540f05SmithA1.jar

Extracting the contents of the jar file, 
recreating the original files, directories, and their contents --

jar xvf csu540f05SmithA1.jar

You might find this little java application, Jaree, useful for quick, visual inspections of jar files. Runs on any platform with Java.

Here are links to notes about creating executable jar files:

Links on double-clickable jars (google: "double-clickable" jar files). One is:

You could also look at how Ant or Ant in Eclipse, creates jar files for you through the Ant Jar Task. There's even a Jar Bundler task for turning a java app into a Mac OS double-clickable app. There is more to learn about jars, but that's enough for now.


Go to CSU540 home page. or RPF's Teaching Gateway or homepage