如果我的格式不對,請給出建議,這是我第一次在這裏發表問題。使用UNIX時,我無法從頂層目錄運行Java程序「Master」(位於子目錄中)。從頂層編譯工作很好,但我實際上無法從頂層運行java代碼。我想我可能會誤解classpath/classpath標誌。我的目錄結構如下所示:/ top-level/src/amsPassageretriever。在子目錄中運行Java程序
當我嘗試運行一切從頂級目錄,我得到以下錯誤:
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.
對不起,我確實犯了一個錯字。我編輯了我的帖子,以更好地解決問題。我嘗試從/頂級運行你的命令行,但我仍然得到相同的錯誤。我嘗試了各種排列與中間/ src文件夾在那裏(src/amsPassageretriever.Master或src.amsPassageretriever.Master),但沒有骰子。 – 2011-05-10 00:48:39
是的,只是發現你的'src'目錄不在你的類路徑中。發佈更新。 – 2011-05-10 00:52:10
太棒了,我只是試着用你的更新和它的作品。謝謝你的幫助! – 2011-05-10 00:54:48