Rudy Rucker's Information about Java

 

Home

Biography

Books

Paintings & Links

Classes

Email

 

 

Developing Java Programs

The situation regarding tools for Java programming is confusing.

First of all you need to get a JDK.
Secondly you need to set some paths on your machine.
Thirdly you need to get some kind of IDE tool for editing and building your files.
Fourthly, you'll need to frequently check the Java documentation online, for instance at Paintings & Links JDK 1.3 Documentation

The JDK

Sun gives away packages with a command-line compiler and libraries for developing Java code; these packages are called JDK (for Java Developer's Kit).  The commonly used editions at this time are  JDK:  1.1, 1.2.2, 1.3, and now 1.4.  JDK 1.2 and higher are referred to be Sun as " Java 2".

In writing a Java program, you use a text editor of some kind to make one or more *.java files.   You use a Sun utility known as javac.exe to compile the *.java files into *.class files.  The compiler will pull in a number of Java library or "package" files from your disk and link them into your code.  And then you execute the *.class files and see a program running by using either (i) a Sun "virtual machine" utility known as java.exe or (ii) a web browser.  The Java libraries, javac.exe, and java.exe all come as part of the JDK.

The various Java JDK (sometimes also called SDK for Software Devloper's Kit) are downloadable from the Web at Sun's java.sun.com site.   A JDK includes, among other things, the javac.exe and java.exe utilites as well as some libraries of *.java code files.  Note that it's okay to install several JDK on your machine, in separate directories.

Another point to mention here is that when you go to the Sun download page, you have a choice of getting the SDK or the Runtime Environment.  Normally you would want the SDK.

The "SDK "includes all the libraries, the javac.exe compiler, the java.exe virtual machine, and a plug-in to (maybe) make the Java files work with your current web browser.

The "Runtime Environment" leaves out the javac.exe compiler, but includes some of the libraries, the virtual machine, and the plug-in.

Download a JDK From Sun. This is about 30 Meg, so do it with a fast connection.

There is another thing you can download, this is the "Documentation".  You definitely would like to get this too To get documentation for the Java SDK, you can download the documentation, which is in HTML format and about 20 Meg.  Alternately, you can browse the documentation online at Paintings & Links JDK 1.3 Documentation or  Paintings & Links Java 1.1 Documentation.

By the way, if you can't manage the huge downloads, you can buy these wares directly from Sun on CD.  Also note that some Sun downloads are only availabe during business hours on weekdays.

The Sun Java SDK does not come with any type of IDE (integerated developer environment).  For simple programs you do best to use Textpad as described below.

Setting your Path

In order to run javac, java, and textpad from the DOS command line your path must include the directories where javac.exe and java.exe live and the directory where textpad.exe lives. On my machine these recently happened to be c:\Program Files\j2sdk1.3.1\bin for the two Java utilities, and c:\Program Files\Textpad 4 for Textpad.

If you have NT, you set the path by opening Start|Settings|Control Panel|System|Environment. Click on the Path line, edit it in the bottom of the dialog, and press Set to record your editing. Separate all path fields by semi-colons but not with spaces. A good path to use in the lab might look like this

c:\Program Files\j2sdk1.3.1\bin;c:\Program Files\Textpad 4

If you have Win98, you will have a C:\autoexec.bat file that you can edit. If you don't find autoexec.bat in the C:\ root, use Start|Find to find it. Use any text editor to add a line like this. The final %path% means to keep whatever was in the path before.

set path=c:\Program Files\j2sdk1.3.1\bin;c:\Program Files\Textpad 4;%path%

On some versions of Win98 (or Win95), a path like
c:\Program Files\Textpad 4
isn't recognized. You can use the DOS versions of the two-word names instead
c:\Program~1\Textpad~1

You know you have the path fixed if you can enter java, javac, and textpad at the command line and get responses other than "...not found."

An Integrated Development Environment (IDE)

If you plan to write Java programs of any size, it would be nice to have an IDE (integrated development environemnt) that has integrated help, which lets you build and run from the edit interface, which highlights errors, and which has some debugging capability.   I still haven't found a Java IDE that I really like. 

There are various goals in choosing your compiler. Unfortunately these goals seem to be incompatible.
(1) An IDE (Integrated Development Environment) similar to, for instance Microsoft Visual Studio, that is, a multi-windowed environment in which we can edit, compile, and run our programs, with ability to pop up help files and perhaps even do some WYSIWYG (What you see is what you get) editing of our GUI (Graphical User Interface).
(2) Write Java applets that are useable by a wide range of browsers.
(3) Run in a stable fashion on your machine.
(4) Support the latest features of Java.
(5) Don't have to do  huge downloads over the Web.
(6) Pay very little.

Textpad 4.6

A good low-end Java developement environment is to install a Sun JDK and use the free TextPad 4.6 editor from www.textpad.com.  This isn't really a full IDE, but it's a lot better than working at the command line.

Spend some time looking at the Textpad menus to get it configured properly. To begin with use View to turn off the Clip Library and Document Selector windows.

You should install Java BEFORE you install Textpad, otherwise you won't be able to add the Java Tools. If Java is already installed, then you can use Configure|Preferences|Tools|Add to add the JDK commands if they are not already present under the Tools menu.

If you don't see the Configure|Preferences|Tools option then you are going have to use the Tools|Run dialog to compile your java. In the Tools|Run dialog fill in javac as the comand, and either filename.java or *.java as the Parameters. You may need to set Initial folder as well. Check DOS Command and check Capture Output. The Run dialog will keep the same selections over a session, so it's useful.

Use Configure|Preferences|Document Classes|Java|Syntax to Enable Syntax Highlighting and select the java.syn syntax file.

You can use Editor|Keystroke compatability to select Microsoft Applications to use the familiar Microsoft shortcuts. You can use Configure|Preferences|Keyboard|Tools to select shortcut keys Ctrl+1 and Ctrl+2 for JDK Compile and JDK Run Application. You can shortcut other keys as well. You can use Configure|Preferences|Document Classes|Default|Font to select bigger fonts. And so on. Textpad has a good help file.

One new feature in 4.6 is that can create a Textpad "workspace" file which opens up a whole bunch of *.java files at once. When you call Tools|Compile, all the open files get compiled.

If there is an error, you see a window with error messages. Double clicking on an error message takes you to it.

Sun ONE (Formerly known as Forte)

Sun provides a free Java IDE called ONE (formerly known as Forte), which is a fairly serviceable IDE for Java development.  You can download it (I think only on weekdays) from Sun's ONE Studio 4.0 For Java Community Edition Download page.  You need at least 128 Meg of RAM on your computer to run this program.

The earlier version called Forte is on our lab machines. In the past, I've found Forte too slow and too unergonomic (you can't use the mouse wheel to scroll and there aren't many hotkey shortcuts, you have to click a lot, and the dialogs aren't standard Windows dialogs) to really be useable.

But ONE is said to be much better than Forte, so give it a look. You can do a combined download of ONE plus the JDK 1.4, at a total of 100 Meg.

One way around the brutally large downloads is to buy the wares on CD from Sun.

BlueJ

You can get BlueJ for free, but it's pretty light-weight and not a powerful tool. The dialogs are hard to use. One nice feature, though, is that it automatically generates a UML diagram of the classes in your code.

VisualAge for Java from IBM

You can download a free copy of this at IBM's VisualAge Download. Note that you need to look for the "Entry Edition" version, and that you may need to fill out some registration dialogs. You have to download two files for the build, the "disk 1" and "disk 2". The software is solid and seems to run well.

Visual Cafe (Out of business)

Borland JBuilder

I've used this some.  It's not bad.  It has the a high-RAM requirement, but it supports any JDK you like.  Check it out at the JBuilder site, I think you can get a free trial version.

Metrowerks

I bought a copy of this for $120, and spent an afternoon trying to build an applet from exiting code I had, and I couldn't. The help files aren't helpful, the fonts are ugly, and I'm sorry I spent money on it.

Microsoft J++ (Obsolete)

This Java compiler is  on some machines in our lab, but is being phased out in favor of Sun One.  In addition, you can rent an installation disk for J++ from the SJSU bookstore for $30 for four days, and install J++ on your home machine. A nice thing about commercial software is that you get the whole thing on one CD and don't have to do any downloads.  JDK, IDE, documentation, all on one handy disk.

J++ is a very nice IDE.  It seems to run easily on most machines, and doesn't require that you have a lot of RAM.  The catch is that J++  doesn't support JDK 1.2 and higher.  Given that JDK 1.2 doesn't run on many browsers, this isn't as a big a handicap as you might think.  And for the code we're going to be writing, JDK 1.1 is close enough to JDK 1.2 for most programs.

Even so, it is annoying not to have the latest and greatest version of Java and for many people, Microsoft's pig-headed and quixotic refusal to support JDK 1.2 and higher is a show-stopper.

Rumor has it that Microsoft will soon make a new Java compiler of some kind called J#.

The Asteroids Applet
This was the main project in the Fall, 1999 semester, and is a substantial Java videogame project.