lord.didger
lord.didger

Reputation: 1407

java runs fine with 'absolute' path, doesn't run with CLASSPATH specified

my program is in package pl.edu.uj.tcs.crazySocket; due to some requirements. I work in the crazySocket directory. In order to compile the program I use command

CLASSPATH=~/prog/colosseum/data javac tictactoe.java

and that succeeds. I want to run the program. I change javac to java and get rid of the '.java'. I get

Exception in thread "main" java.lang.NoClassDefFoundError: tictactoe
Caused by: java.lang.ClassNotFoundException: tictactoe
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)

when I get up in the tree directory to the ~/prog/colosseum/data and run java pl/edu/uj/tcs/crazySocket/tictactoe all works fine.

What's wrong with the CLASSPATH? Shouldn't it work both with javac and java?

Upvotes: 0

Views: 553

Answers (1)

Mat
Mat

Reputation: 206869

There's nothing wrong with your classpath, it's your call to java that's wrong.

You need to specify the full qualified class name pl.edu.uj.tcs.crazySocket.tictactoe.

Upvotes: 1

Related Questions