Mac 索引和 CLASSPATH 问题 - java.lang.NoClassDefFoundError
系统属性: 爪哇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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你所经过的路径是问题所在。尝试将以下内容添加到您的bash脚本中
问题是,当您运行时,
您正在告诉java运行包中的类
.
I think the path you're passing is the problem. Try adding the following to your bash script
The problem is that when you run
you are telling java run the class in the package
.