Mac 索引和 CLASSPATH 问题 - java.lang.NoClassDefFoundError

发布于 2024-10-17 08:49:55 字数 1794 浏览 1 评论 0原文

系统属性: 爪哇1.6 Mac OSX 版本 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和一个网络示例

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

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:

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 文件。有人知道为什么我会收到戏剧错误吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ま柒月 2024-10-24 08:49:55

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

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运行包中的类

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

.

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

.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文