Re: set classpath correctly
Mitchell_Collen wrote:
Lew,
Does the commands that you provided have to typed every everytime I open a
DOS window? I was wondering because I thought if a user set the classpath on
the system then all they'd have to do to compile is type javac program.java
and that's it.
Lew wrote:
I am very new to Java and any programming besides a little sql. Will
you tell
[quoted text clipped - 17 lines]
Second rule, you need to set the PATH to include the JDK\bin directory
so that javac.exe can be found.
Third rule: don't set the CLASSPATH.
Instead, use the -classpath (a.k.a., -cp) option to javac and to java.
cd $project/src
javac -classpath ../build/classes -d ../build/classes \
com/lewscanon/foo/Main.java
javac -cp ../build/classes -d ../build/classes \
com/lewscanon/foo/Main.java
java -classpath ../build/classes com.lewscanon.foo.Main
java -cp ../build/classes com.lewscanon.foo.Main
99.9% of the time you don't need a CLASSPATH. You aren't going to have
to type it ever probably or if you do it will be in your build script.
When you make your package directories, use a single root and life will
be simple.
--
Knute Johnson
email s/nospam/knute/