[英]Java Lucene Classpath problems ubuntu
I'm having problems trying to run a Java file that uses Apache Lucene. 我在尝试运行使用Apache Lucene的Java文件时遇到问题。
I can compile it since I have the .jar file in my classpath but when I want to run the .class file, I have to add this parameter -classpath .:lucene-core.xxjar
, if I don't I get this error: 我可以编译它,因为我的类路径中有.jar文件,但是当我想运行.class文件时,我必须添加此参数
-classpath .:lucene-core.xxjar
,如果不这样做,则会出现此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: HelloLucene
Caused by: java.lang.ClassNotFoundException: HelloLucene
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: HelloLucene. Program will exit.
Do I have to add the classpath to the jvm also? 我也必须将类路径添加到jvm吗? If so how do I do this?
如果是这样,我该怎么做?
Here's the output I get when I echo my CLASSPATH: 这是我回显CLASSPATH时得到的输出:
ricardo@ricardo-laptop:~/Desktop/lucene/Indexer$ echo $CLASSPATH
/home/ricardo/lucene-3.4.0/lucene-core-3.4.0.jar:/home/ricardo/lucene-3.4.0/contrib/demo/lucene-demo-3.4.0.jar
The class that's not found is your class, ie HelloLucene
. 找不到的类是您的类,即
HelloLucene
。 Not the library. 不是图书馆。
Your class is probably compiled under bin
or target/classes
, so your classpath has to point whereever it is, ie 您的类可能是在
bin
或target/classes
下编译的,因此您的类路径必须指向任何位置,即
-classpath target/classes:...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.