You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by Anshul <an...@gmail.com> on 2013/07/14 11:59:36 UTC

Unable to find class

I am new to lucene and am trying to configure it to my windows.I have setup
lucene-demo and lucene-core in my classpath as below :

Path =
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
Files\TortoiseSVN\bin;C:\Java\jdk1.6.0_37;C:\Users\celigonew\Desktop\ant1.9.0\apache-ant-1.9.0\bin;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\lucene-core-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\demo\lucene-demo-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\analyzers\common\lucene-analyzers-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\queryparser\lucene-queryparser-3.6.2.jar

But still when i try indexing docs in lucene-3.6.2 folder it throws the
following errors.
Any suggestions...


C:\Users\celigonew>java -cp
C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\demo\lucene-demo-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\core\lucene-core-3.6.2.jar
org.apache.lucene.demo.IndexFiles -docs
C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\docs;

Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/lucene/demo/IndexFiles
Caused by: java.lang.ClassNotFoundException:
org.apache.lucene.demo.IndexFiles
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.apache.lucene.demo.IndexFiles.  Program
will exit.










--
View this message in context: http://lucene.472066.n3.nabble.com/Unable-to-find-class-tp4077861.html
Sent from the Lucene - General mailing list archive at Nabble.com.

Re: Unable to find class

Posted by Koji Sekiguchi <ko...@r.email.ne.jp>.
Welcome Anshul!

(13/07/14 18:59), Anshul wrote:
> I am new to lucene and am trying to configure it to my windows.I have setup
> lucene-demo and lucene-core in my classpath as below :

There seems to be some points:

1. Use java-user@lucene.apache.org mailing list for Lucene-java specific problems.

> Path =
> %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program
> Files\TortoiseSVN\bin;C:\Java\jdk1.6.0_37;C:\Users\celigonew\Desktop\ant1.9.0\apache-ant-1.9.0\bin;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\lucene-core-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\demo\lucene-demo-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\analyzers\common\lucene-analyzers-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\contrib\queryparser\lucene-queryparser-3.6.2.jar

2. You don't set classpath in this way. Use CLASSPATH environment variable rather than Path.
(I don't have Windows, but I believe it is same rules of Linux or Mac.)

> But still when i try indexing docs in lucene-3.6.2 folder it throws the
> following errors.
> Any suggestions...
>
>
> C:\Users\celigonew>java -cp
> C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\demo\lucene-demo-3.6.2.jar;C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\core\lucene-core-3.6.2.jar
> org.apache.lucene.demo.IndexFiles -docs
> C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\docs;

3. Looks fine as specifying -classpath or -cp overrides any setting of the CLASSPATH
environment variable.

> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/lucene/demo/IndexFiles
> Caused by: java.lang.ClassNotFoundException:
> org.apache.lucene.demo.IndexFiles
>          at java.net.URLClassLoader$1.run(Unknown Source)
>          at java.security.AccessController.doPrivileged(Native Method)
>          at java.net.URLClassLoader.findClass(Unknown Source)
>          at java.lang.ClassLoader.loadClass(Unknown Source)
>          at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>          at java.lang.ClassLoader.loadClass(Unknown Source)
> Could not find the main class: org.apache.lucene.demo.IndexFiles.  Program
> will exit.

4. Looks Java VM cannot find org.apache.lucene.demo.IndexFiles class.
Verify the class exists in jar file via:

C:\> jar tf C:\Users\celigonew\Desktop\CE\Lucene\lucene-3.6.2\demo\lucene-demo-3.6.2.jar

Hope this helps.

koji
-- 
http://soleami.com/blog/automatically-acquiring-synonym-knowledge-from-wikipedia.html