I am new to java and have used it in netBeans but have never tried to compile or run it from terminal. So, my question may look naive. I have a directory of this structure:
Folder X
contains:
couple of files and a folder named esa-lucene
.
esa-lucene
is a directory having three folders src, lib, web
:
.classpath, lib, .project, .settings, src, web
and I am trying to run a java file " ESAWikipediaIndexer.java
" which exists in this subdirectory:
X/esa-lucene/src/edu/wiki/index/ESAWikipediaIndexer.java
I cd into Folder X
and use this:
java -cp esa-lucene.jar edu.wiki.index.ESAWikipediaIndexer
But it gives me this error:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/wiki/index/ESAWikipediaIndexer
Caused by: java.lang.ClassNotFoundException: edu.wiki.index.ESAWikipediaIndexer
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: edu.wiki.index.ESAWikipediaIndexer. Program will exit.
also I've checked .classpath and it contains:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/lucene-analyzers-3.0.0.jar"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/lucene-core-3.0.0.jar"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/mysql-connector-java-5.1.12-bin.jar"/>
<classpathentry kind="lib" path="web/WEB-INF/lib/trove-2.1.0.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
I've checked the lib
and web/WEB-INF/lib/
folders as well and all the required external libraries (jar files) also exist in this folder.
I searched to find any solution and tried a couple of things but none of them worked. Have no clue how to make it work!
BTW, apparently people have used this package before, and I just downloaded to use it too but wasn't successful so far.