Featured Whitepapers
Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Overcoming installation difficulties

Getting Java installed so we can have some serious fun. <br><em>Plus:</em> Answers to your questions

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
This month we start off with a discussion of some of the common problems that people face when trying to get Java to work for them. After that we jump into some reader mail.

Installation

Some people are having difficulty installing and running Java programs. Given the growing variety of Java development tools, this issue is becoming much more complex. Now there are ports of Sun's Java Development Kit (JDK) to a wide number of platforms as well as a growing contingent of proprietary Java development tool options. Each of these tools on each platform has its own idiosyncrasies and bugs.

RTFM

By far the most common problem is that people don't read the documentation that comes with the tools. Although it seems like such a simple thing, there is something about documentation that repels us. It's best to start by skimming the installation and setup documentation once to get an idea of what's going on and then go back through it, carefully following the instructions.

Some of the documentation for the various toolsets are platform-specific, so make sure you are reading the sections appropriate to your situation. For instance, Sun's JDK tool reference pages are segregated into Solaris and Microsoft Windows sections.

In addition to reading the printed documentation, be sure to read any notes or README files that come with the toolset. All of the Java vendors have Web pages with lots of potentially helpful information, including patches/updates to the tools themselves and additional documentation like Frequently Asked Questions (and answers) files.

CLASSPATH

Setting the CLASSPATH environment variable is the next most common problem. It is spelled out in the documentation of the various toolkits, but it still seems to throw people for a loop.

The purpose of the CLASSPATH variable is to let the various tools know where to find the Java class files. It is a list of directories in which the tools should start their search for the class files.

Under Microsoft Windows platforms the list elements are separated by semicolons like so:

set CLASSPATH=.;c:\code\java;c:\java\lib


That would tell, for example, the Java compiler to look first in the current directory, then in my local Java coding directory, and finally in the JDK library directory.

Under Unix-like platforms, the list elements are separated by colons like so:

setenv CLASSPATH .:/home/john/java/code:/usr/local/java/classes/classes.zip


This tells it to look first in the current directory, then in my local Java coding directory, and finally in the JDK classes archive.

A particularly annoying problem with the CLASSPATH environment variable is that it's used by both the development tools and at least some of the Java-enabled browsers (such as Netscape's Navigator). That can make for an unfortunate clash of class files. My solution is to wrap my use of the tools and the browsers inside shell scripts and batch files. These wrappers set the CLASSPATH as appropriate for the program it then invokes.

The wrapper solution also makes it a lot simpler to use multiple toolsets and browsers without them stomping all over each other. Typically, I have two different versions of Netscape Navigator (v.2.0 and v.3.0 beta) along with a couple of versions of the JDK and appletviewer (an older, more "stable" version along with the latest, cutting-edge version).

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources