Java Information

General Information

If you have not used Java before, go to the on-line tutorial referenced below. Then learn Swing, and then Java3D. Do not bother with the graphics capabilities of Swing, since we will use Java3D instead.

I also have a set of simple examples on line in the course account in the scf facility at

~cs582/public/java

This is an scf account, not a URL. A few of these examples are adapted from the book "Java by Dissection" by I. Pohl and C. McDowell, Addison-Wesley, 2000.

There are 3 directories. I suggest that you look at the examples in the following order:

TextExs: These just write to the terminal

SwingExs:

3dExs:


Software

We will be using the following production versions of Java, Swing and Java3D.

These should be available in the machines used for the class. In the scf SUNs you need to add to your .login file the following:

if (-e /usr/usc/jdk/default/setup.csh) then
source /usr/usc/jdk/default/setup.csh
endif

I recommend using the compilers directly. In the SUNs, use a terminal window in the CDE environment. Last time I tried, Java 3D did not work in the Gnome environment.

javac ClassName.java

compiles the source into byte code, ClassName.class. Then

java ClassName

runs it. If you have all the source files in the same directory, the system will find what it needs and compile it. Note that the compiler may produce more files than what you expect, and that all are needed and must be submitted.


Development on PCs

In principle, the code can also be developed on a PC, and even the byte code (i.e., the compiled version) developed on a PC should run on a SUN. Important Note: Do not assume that code developed in another machine will run in the SUNs without testing it there. If your code does not run in the SUNs we use for testing you will get a zero for execution.

Those of you who have PCs may wish to download the software for free as follows:
jdk 1.5.0 -- Java web site.
j3d 1.3.2 -- Java3D web site.
Make sure that you get the versions we are using.

In the PCs the jdk should install without any problems. Now, for j3d the situation is more complicated because no installer is available. Here is the recipe for a PC running XP:

1. Download java3d-1_3_2-windows-i586.zip to the desktop (for example)
2. Unzip it. You'll find 6 files (readme, etc.). The one you need is j3d-132-win.zip.
3. Move this file to the jre directory of the jdk directory. Beware that there is also an independent jre directory not under jdk. In a normal installation the desired directory is c:\Program Files\Java\jdk1.5.0_06\jre.
4. Unzip the file in this directory and extract all files.
5. Verify that the 3 files j3d*.dll end up in c:\Program Files\Java\jdk1.5.0_06\jre\bin.
6. Verify that 2 files j3d*.jar and vecmath.jar end up in c:\Program Files\Java\jdk1.5.0_06\jre\lib\ext.

The PC installation has a couple of environmental requirements: (i) you need to have in your PATH variable the value c:\Program Files\Java\jdk1.5.0_06\bin ahead of other entries, or at least ahead of the system directories (assuming that you installed Java in the usual place) or you won't find the javac compiler; and (ii) your CLASSPATH variable must be set to '.' or not set at all, or Java will not find the class files it needs. To set these variables in XP go to Start >> Control Panel >> System >> Advanced >> Environment Variables and scroll to edit 'Path' in the system variables.

Other Versions

The newest PC (and SUN, for that matter) versions are Java SE 6 or jdk 1.6.0 and Java 3D 1.5.1. I do not know how compatible these are with the versions we are using for testing your programs in the SUNs. So, use at your own risk and make sure you test your programs in the scf SUNs before you submit them. The new versions are easier to install in the PCs than the older versions mentioned above.

Last time I tried I couldn't use the J++ development environment with Swing. Also note that if you use the nice graphic facilities of J++, your byte code will not run in the SUNs, so this is out.

SUN also has an integrated development environment (IDE) called NetBeans, which can be used to develop GUIs. I don't know if the code developed by NetBeans will be compatible with the SUNs used for grading your programs. So, again, use at your own risk! My feeling is that writing the GUI code by hand for the simple things we are doing is easy enough and more instructive than using GUI builders.


Documentation

There are many texts available on Java. I recommend the on-line tutorials available at the java web sites. NOTE:The information on how up to date the documentation is, is not up to date itself :-). It's true as of a couple of years ago, and I'm sure there have been changes. Beware!

Reference manuals for the APIs are also available on line in html format.

USCweb
Copyright © 1996 The University of Southern California. All RIGHTS RESERVED.
All trademarks mentioned herein belong to their respective owners.
Last Update: January 9, 2008 - Ari Requicha, requicha "At' usc.edu.