Mac索引和CLASSPATH问题-java.lang.NoClassDefFoundError [英] Mac Indexing and CLASSPATH problems - java.lang.NoClassDefFoundError

查看:148
本文介绍了Mac索引和CLASSPATH问题-java.lang.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

系统属性: Java 1.6 Mac OSX版本10 蚂蚁1.8

System properties: Java 1.6 Mac OSX version 10 Ant 1.8

方案:我正在完成我的最后一个项目,即创建一个网站,该网站使用Lucene搜索我的网站和数据库.我在这里通过Lucene演示进行工作 http://lucene.apache.org/java/2_3_2/demo.html 谈论类路径 http://lucene.apache.org/java/2_3_2/demo3.html 和一个网络示例

Scenario: I am working on my final year project which is to create a website which uses 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

我已经在主目录/Users/philhunter/中创建了一个.bash_profile文件,该文件设置了我的类路径:

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

当我尝试运行命令时,它在命令行上询问我正在收到ClassDefNotFoundError:

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)

命令行命令是:

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

应将我的网站文件编入索引.该indexHTML文件是上面最后一个类路径目录中的一个java文件.谁知道我为什么会收到剧院错误!?

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!?

推荐答案

我认为您通过的路径是问题所在.尝试将以下内容添加到您的bash脚本中

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/

问题在于,当您运行

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

您正在告诉Java运行包

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

中的类.

这篇关于Mac索引和CLASSPATH问题-java.lang.NoClassDefFoundError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆