0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

you mean that I have to run the program from the base directory? I can't work solely in the crazySocket directory?
No, you can work from wherever you want. But you always (regardless of where you are) need to pass the full qualified class name to java.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.