Running Generic Java Applications
There are many Java developers who write code and never consider that their application might someday run on a Mac. After all, the whole concept behind Java is that the code can be written once and run anywhere. In many cases, these programs will run fine on Mac OS X. One of the biggest advantages of including a JVM with every Mac is the large number of programs that are enabled on the platform. In this section you will see how to run Java programs that aren’t specifically packaged for use on a Mac.
Running from jar Files
You have seen that a jar file is a Java archive
much like a zip or tar
file. Try this out:
Make a copy of the file
Jar Bundler.jarthat you found inside the JarBundler application.Make a copy of
Jar Bundler.jarwith the nameJarBundler.zip.Expand the
JarBundler.zipfile using the version of StuffIt Expander included with Panther.
When you do, you end up with a folder containing many class files and
two subdirectories. The META-INF folder contains
a single file named, MANIFEST.MF. This directory
and file are what differentiates a jar file from
a zip file. The MANIFEST.MF
file may contain the name of the Java class file intended
to initiate the application; this makes the jar
file double-clickable.
There are many advantages to working with jar
files instead of the individual class files. When you zip up a bunch of files scattered across directories, not only is the result compressed and smaller than the sum of the individual files, you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access