开发者

Mac Indexing and CLASSPATH problems - java.lang.NoClassDefFoundError

开发者 https://www.devze.com 2023-02-10 03:47 出处:网络
System properties: Java 1.6 Mac OSX version 10 Ant 1.8 Scenario:I am working on my final year project which is to create a website which uses 开发者_C百科Lucene to search my website and my database.

System properties: Java 1.6 Mac OSX version 10 Ant 1.8

Scenario: I am working on my final year project which is to create a website which uses 开发者_C百科Lucene to search my website and my database. I am working through lucene demos here http://lucene.apache.org/java/2_3_2/demo.html which talks about classpath http://lucene.apache.org/java/2_3_2/demo3.html and a web example

I have created a .bash_profile file in my home directory /Users/philhunter/ which sets my classpaths:

CLASSPATH=${CLASSPATH}:/Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/lucene-core-3.0.3.jar
CLASSPATH=${CLASSPATH}:/Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/lucene-demo-3.0.3.jar
CLASSPATH=${CLASSPATH}:/Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/src/demo/org/apache/lucene/demo

When i try and run the commands it asks on the command line i am getting ClassDefNotFoundError:

Exception in thread "main" java.lang.NoClassDefFoundError: /Users/philhunter/Desktop/COM562_Project/lucene-3/0/3/src/demo/org/apache/lucene/demo/IndexHTML
Caused by: java.lang.ClassNotFoundException: .Users.philhunter.Desktop.COM562_Project.lucene-3.0.3.src.demo.org.apache.lucene.demo.IndexHTML
    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:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

The command line command is:

java /Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/src/demo/org/apache/lucene/demo/IndexHTML -create -index /Applications/MAMP/htdocs/

which should index my website files. That indexHTML file is a java file in that last classpath directory above. Anyone know why I am getting theat error!?


I think the path you're passing is the problem. Try adding the following to your bash script

cd /Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/src/demo/
java org.apache.lucene.demo.IndexHTML -create -index /Applications/MAMP/htdocs/

The problem is that when you run

java /Users/philhunter/Desktop/COM562_Project/lucene-3.0.3/src/demo/org/apache/lucene/demo/IndexHTML

you are telling java run the class in the package

Users.philhunter.Desktop.COM562_Project.lucene-3.0.3.src.demo.org.apache.lucene.demo
.

0

精彩评论

暂无评论...
验证码 换一张
取 消