[英]java runs fine with 'absolute' path, doesn't run with CLASSPATH specified
my program is in package pl.edu.uj.tcs.crazySocket;
我的程序在
package pl.edu.uj.tcs.crazySocket;
due to some requirements. 由于某些要求。 I work in the crazySocket directory.
我在crazySocket目录中工作。 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'.
我将javac更改为java,并摆脱了“ .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. 当我在树目录中找到〜/ prog / colosseum / data并运行
java pl/edu/uj/tcs/crazySocket/tictactoe
一切正常。
What's wrong with the CLASSPATH? CLASSPATH有什么问题? Shouldn't it work both with javac and java?
它不能同时与javac和java一起使用吗?
There's nothing wrong with your classpath, it's your call to java
that's wrong. 您的类路径没有错,是您对
java
的调用错了。
You need to specify the full qualified class name pl.edu.uj.tcs.crazySocket.tictactoe
. 您需要指定完整的合格类名称
pl.edu.uj.tcs.crazySocket.tictactoe
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.