[英]Classpath exported OK,java Class.class invokes error
executed ok: 执行确定:
export CLASSPATH=/home/sergio/workspace/teal
Anon.class
resides in teal
directory Anon.class
驻留在teal
目录中
both java Anon
or java -cp /home/sergio/workspace/teal Anon
invoke classical: java Anon
或java -cp /home/sergio/workspace/teal Anon
调用经典:
Exception in thread "main" java.lang.NoClassDefFoundError: Anon
Have I missed something in CLASSPATH declaration? 我是否错过了CLASSPATH声明中的某些内容?
If the package of your class is teal
, you should be exporting the classpath "till" the package directory, not into it. 如果您的类的包是
teal
,那么您应该将类路径“直到”导出到包目录,而不是导出到该目录。
export CLASSPATH=/home/sergio/workspace/
To make it more generic, if the package of a class Bar
is com.foo
and the directory structure looks like, 为了使其更通用,如果
Bar
类的包是com.foo
并且目录结构看起来像这样,
[+] classes/
[+] com/
[+] foo/
[-] Bar.class
You should set classpath till classes
only. 您应该将类路径设置为仅
classes
。
You need to have "." 您需要输入“。” in your classpath.
在你的classpath中。
For Unix this is done with 对于Unix,这是通过
export CLASSPATH=/home/sergio/workspace/teal:.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.