Re: Novice linux java coder needs help getting progs to run
I'm just starting to teach myself java and as such I've installed the
latest jre1.6 and jdk1.6 for Linux from Suns website into /usr/local. I've
set my PATH to point to /usr/local/jre1.6.0_16/bin, /usr/local/jre1.6.0_16,
/usr/local/jdk1.6.0_16/bin and /usr/local/jdk1.6.0_16/. Also I've set
my CLASSPATH to point to /usr/local/jre1.6.0_16/lib:.
Besides the advice given by others, there are a couple of other points worth
It's not necessary to have both the JRE and the JDK installed. The JDK is a
superset of the JRE (i.e. it includes the JRE). Having both won't hurt, it just
isn't necessary. If you look in /usr/local/jdk1.6.0_16/ you'll see that it has
the jre subdirectory, which contains everything which the JRE does. You also
don't need to set your PATH to point to both the JDK and the JRE, the JDK/bin
directory contains everything you need to both compile and run Java. The
JDK/jre/bin (or JRE/bin) directory contains what you need just to run Java.
The second point is that it is generally unnecessary to set CLASSPATH. I'd say
that, unless it's really is necessary, you are far better off not setting it at
all because it causes more confusion than it alleviates. You can do everything
that CLASSPATH does by specifying the classpath on the java command line with
the -cp argument. Until you get used to how classpaths work you are going to
learn much more by explicitly setting it on the java command line than you are
by forgetting to set CLASSPATH correctly and getting NoClassDefFoundError. Once
you understand classpaths you can use CLASSPATH to save you some typing, but
it's best not to have it set universally at login.
I would second that advice given by Bugbear, online tutorials can be a really
good place to start, and the Sun Tutorial is particularly good. For example,
the tutorial pointed to by Bugbear gives step-by-step instructions on how to
create a Java application on Linux.