Sun allows you to download either the JRE (Java Runtime Environment) or the JDK (Java Development Kit; also known as the Java SDK). (As of late 2004, Sun also allows you to download the NetBeans IDE together with the JDK.) The JRE does not include the compiler (or other development tools) and thus is not for us; it's for people who just want to run Java programs. The Java libraries have seen several large upgrades since Java first appeared on the scene in 1995: JDK1.1 was the standard for a while, but the jump to JDK1.2 was significant, and all versions at 1.2 and beyond are often referred to as "Java2" or "J2SDK". With JDK1.5, the language is known as "Java 5.0". From there, who knows?
At some point, Sun made available versions of the Java libraries that were geared for servers (the Enterprise Edition) and for phones, embedded chips, etc. (the Micro Edition). The "normal" version (that we will be using) is referred to as the Standard Edition. So J2SE refers to any version of the Java Development Kit at v1.2 or later, with the Standard Edition libraries.
All versions of the Mac OS before OS X only support Java 1.1.8. Thus those platforms are not appropriate for development in this course. Mac OS X, however, includes Java 1.4.2 with installation. (or through Software Update). The newest release of Mac OS X, "Tiger" supports installation of Java 5.0 (follow this link. (Note that "Tiger" is also the codename for Java 5.0; this is an unfortunate coincidence.)
The most important tools that are installed when you install the JDK are
javacThe Java compiler can be used at the command line simply by providing it the name of your code file:
% javac MyFile.java(Note that I use
% to mark the command prompt.) For this
compile
attempt to work, the current directory must contain
"MyFile.java", and javac must be in the path that
the system searches for executables. (The installation of the
JDK should have set this up for you. If entering just
javac at the command prompt yields some error
about it not being recognized as a valid command, it's not in
the path.)
If the compile attempt is successful, you will see nothing output by the compiler. However, the file "MyFile.class" has been created: it contains the bytecode that corresponds to your Java source code. If the compile attempt is unsuccessful, you will see one or more error messages.
javajava is the interpreter (a "virtual machine") that
you will use to run your Java programs. You simply tell it the
name of the ".class" file that you want to run (omitting the
".class" extension).
% java MyClass
Any output produced by your program will appear on the screen. If your program is graphical, the appropriate windows will pop up.
appletviewerappletviewer command.
An applet must be embedded in an HTML file, the simplest of
which might look like:
<html>
<body>
<applet code="MyClass"
height="400" width="400">
</applet>
</body>
</html>
where "MyClass.class" sits in the same directory as this HTML
file, which might be called "testMyClass.html". You can then
invoke your applet through the HTML with:
% appletviewer testMyClass.html
javadocjavadoc on your code file, or directory of code files, will create a website of documentation for your software!
jarjar tool is what you
use. It's really just a "zip" file, with an extra file called
MANIFEST that holds some meta-information about your code. The
syntax for jar is quite similar to Unix
tar, in case that helps.
javapjavap will do that for you.
These tools each have Unix-style "manual pages" available, which can be browsed online at Oracle's Website.