Re: Running java programs from class files
Babu Kalakrishnan wrote:
Knute Johnson wrote:
Oliver Wong wrote:
"Knute Johnson" <nospam@rabbitbrush.frazmtn.com> wrote in message
news:qe%Ig.2$bR.0@newsfe06.phx...
Babu Kalakrishnan wrote:
The commandline for the above example in that case would be :
java -classpath /xyz/abc MyPackage.MyClass
That doesn't work for me although I have seen reference to it before
like that. Could it be that it doesn't work on Windows like that?
It works for me on WinXP SP2:
java -cp "D:\Oliver's Documents\Workspace\Test\bin" D
to run a class called "D" with no package whose classfile is in
"D:\Oliver's Documents\Workspace\Test\bin"
- Oliver
That does for me too. But put it in a package and it won't.
Interesting - Seems to work for me even with classes within a package -
Running TCPServer.class in package test :
java -classpath "C;\Documents and
Settings\Babu\workspace\TestServer\classes" test.TCPServer
Main: Listening for connections on port 2345
Testing on XP Home SP2
BK
package test;
public class Test {
public static void main(String[] args) {
System.out.println("It works!");
}
}
C:\>javac test/Test.java
C:\>java test.Test
It works!
C:\>cd test
C:\test>java -cp "C:\test" test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\test>java -cp /test test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\test>java test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\test>java -cp "C:/test" test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\test>cd \
C:\>java -cp "C:\test" test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\>java -cp /test test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\>java -cp test test.Test
Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
C:\>
What am I doing wrong here?
--
Knute Johnson
email s/nospam/knute/