I'm having problems trying to run a Java file that uses Apache Lucene.
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.x.x.jar
, if I don't I get this error:
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? If so how do I do this?
Here's the output I get when I echo my 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