将RiTa导入Java程序时遇到问题。我在Ubuntu 17.10上使用命令行。
rita.jar rita.support.jar test.class test.java
john@COMPUTER:~/CS/249/bored$ jar tvf rita.jar
0 Mon Jul 16 23:13:02 EDT 2018 META-INF/
104 Mon Jul 16 23:13:00 EDT 2018 META-INF/MANIFEST.MF
7684 Mon Jul 16 23:13:00 EDT 2018 JWNLResource_en.properties
561 Mon Jul 16 23:13:00 EDT 2018 PrincetonResource_en.properties
0 Mon Jul 16 23:13:00 EDT 2018 rita/
17289 Mon Jul 16 23:12:42 EDT 2018 rita/RiGrammar.class
19439 Mon Jul 16 23:12:42 EDT 2018 rita/RiLexicon.class
25441 Mon Jul 16 23:12:42 EDT 2018 rita/RiMarkov.class
18392 Mon Jul 16 23:12:44 EDT 2018 rita/RiString.class
713 Mon Jul 16 23:12:44 EDT 2018 rita/RiTa$1.class
670 Mon Jul 16 23:12:44 EDT 2018 rita/RiTa$RiTaLoaderSource.class
44101 Mon Jul 16 23:12:44 EDT 2018 rita/RiTa.class
3146 Mon Jul 16 23:12:44 EDT 2018 rita/RiTaEvent.class
706 Mon Jul 16 23:12:44 EDT 2018 rita/RiTaException.class
860 Mon Jul 16 23:12:44 EDT 2018 rita/RiText$1.class
54832 Mon Jul 16 23:12:44 EDT 2018 rita/RiText.class
1243 Mon Jul 16 23:12:44 EDT 2018 rita/RiWordNet$ComparableIndexWord.class
50132 Mon Jul 16 23:12:44 EDT 2018 rita/RiWordNet.class
603 Mon Jul 16 23:13:00 EDT 2018 rita/open.gif
1114374 Mon Jul 16 23:13:00 EDT 2018 rita/rita_dict.js
300561 Mon Jul 16 23:13:00 EDT 2018 rita/rita_lts.js
388 Mon Jul 16 23:13:00 EDT 2018 rita/save.gif
john@COMPUTER:~/CS/249/bored$ javac -cp "./*" test.java
john@COMPUTER:~/CS/249/bored$ java test
Exception in thread "main" java.lang.NoClassDefFoundError: rita/RiString
at test.main(test.java:5)
Caused by: java.lang.ClassNotFoundException: rita.RiString
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
如您所见,rita.jar
似乎包含RiString
。 test.java
只是尝试导入rita.*
,然后制作一个RiString
。
答案 0 :(得分:0)
弄清楚了。原来我只是不知道如何正确运行它。
java -cp ".:./*" test