The infamous classpath problem is haunting me. Let me describe the situation:
I have
Java SOURCE files (package: Services.Impl) in this directory:
c:\Server\Services\Impl I have a
single batch file in
c:\Server that compiles the files into
c:\ROOT\Services\Impl with this line:
javac -d ..\ROOT\Download\ .\Services\Impl\*.java That same batch file then executes the program using this line:
java -cp ..\ROOT\Download\ Services.Impl.RunServer In the main() of RunServer I reference a couple of classes located in a jar file that is specified in the classpath in Environment Variables|System Variables:
Variable: CLASSPATH
Value: C:\jdk1.3.1_01\lib\log4j.jar;
But when I try to run the program I get this error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
at Services.Impl.RunServer.main(RunServer.java:43) Here's the kicker:
1) I've got import org.apache.log4j.PropertyConfigurator; and I get
NO compile errors telling me that class can't be found or can't resolve symbol. Everything compiles correctly
2) I can get rid of that error if I add the path and filename to the -cp option when I run the program. So the working command looks like this:
java -cp ..\ROOT\Download\;c:\jdk1.3.1_01\lib\log4j.jar; Services.Impl.RunServer Does anyone have a clue as to why I have to do that? Like I said, I specify that exact same path and filename in my Win2k Environment Variables. This is perplexing...
[ March 06, 2002: Message edited by: David Duran ]