如果我的格式错误,请提出建议,这是我第一次在这里发帖提问。使用UNIX,我无法从顶级目录运行Java程序“Master”(位于子目录中)。编译在顶层工作得很好,但我实际上无法从顶层运行java代码。我想我可能会误解classpath / classpath标志。我的目录结构如下:/ top-level / src / amsPassageretriever。
当我尝试从顶级目录运行所有内容时,出现以下错误:
user:~/top-level$ javac -classpath :/NLP_TOOLS/info_retrieval/lucene/latest/lucene-core-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/demo/lucene-demo-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/wordnet/lucene-wordnet-3.1.0.jar:/NLP_TOOLS/info_retrieval/lemur/latest/share/indri/indri.jar src/amsPassageretriever/*.java
user:~/top-level$ java -classpath :/NLP_TOOLS/info_retrieval/lucene/latest/lucene-core-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/demo/lucene-demo-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/wordnet/lucene-wordnet-3.1.0.jar:/NLP_TOOLS/info_retrieval/lemur/latest/share/indri/indri.jar src/amsPassageretriever/Master
Exception in thread "main" java.lang.NoClassDefFoundError: src/amsPassageretriever/Master (wrong name: amsPassageretriever/Master)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: src/amsPassageretriever/Master. Program will exit.
答案 0 :(得分:1)
java
的参数不是文件,它是类路径(要执行的主类)中类的完全限定类名。
听起来像你想要的课程是amsPassageretriever.Master
(我假设你在帖子的最后发了一个拼写错误的包amsPassageretrieve
)。
因此你应该调用:
java -classpath :/NLP_TOOLS/info_retrieval/lucene/latest/lucene-core-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/demo/lucene-demo-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/wordnet/lucene-wordnet-3.1.0.jar:/NLP_TOOLS/info_retrieval/lemur/latest/share/indri/indri.jar amsPassageretriever.Master
<强>更新强>
如果您希望它不在src
时正常运行,那么您还需要将该目录添加到类路径中:
java -classpath /home/user/top-level/src:/NLP_TOOLS/info_retrieval/lucene/latest/lucene-core-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/demo/lucene-demo-3.1.0.jar:/NLP_TOOLS/info_retrieval/lucene/latest/contrib/wordnet/lucene-wordnet-3.1.0.jar:/NLP_TOOLS/info_retrieval/lemur/latest/share/indri/indri.jar amsPassageretriever.Master
答案 1 :(得分:0)
尝试java amsPassageretrieve.Master
,因为amsPassageretrieve是我能看到的包
如果您的班级需要
,您可能还需要添加类路径变量答案 2 :(得分:0)
您输入的是“检索”和“检索器”,它们是两个不同的单词