Lucene 跑demo碰到的问题
2012-12-02 10:59
316 查看
想运行一下Lucene官网上的小程序,配置好Classpath可是还是不能运行。原文信息如下:
Once you've gotten this far you're probably itching to go. Let's build an index! Assuming you've set your CLASSPATH correctly, just type:
java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src
This will produce a subdirectory called index which will contain an index of all of the Lucene source code.
To search the index type:
java org.apache.lucene.demo.SearchFiles
You'll be prompted for a query. Type in a swear word and press the enter key. You'll see that the Lucene developers are very well mannered and get no results. Now try entering the word "string". That should return a whole bunch of documents. The results will
page at every tenth result and ask you whether you want more results.
我配置好CLASSPATH,可是结果如下:
D:\>java org.apache.lucene.demo.IndexFiles -docs F:\lib\lucene\lucene-3.5.0-src\
lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/dem
o/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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.apache.lucene.demo.IndexFiles. Program will
exit.
百思不得其解。不知为何总出现这样的结果。后来改变了命令行的输入,问题解决,就这么个小小的错误,耗费了N个小时。
新输入的命令行:
D:\>java -cp C:\abc\lucene-core-3.5.0.jar;C:\abc\lucene-demo-3.5.0.jar org.apache.lucene.demo.IndexFiles -docs F:\lib\lu
cene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo
结果如下:
Indexing to directory 'index'...
adding F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\IndexFiles.java
adding F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\SearchFiles.java
407 total milliseconds
接着输入检索命令结果如下:
D:\>java -cp C:\abc\lucene-core-3.5.0.jar;C:\abc\lucene-demo-3.5.0.jar org.apache.lucene.demo.SearchFiles
Enter query:
String
Searching for: string
2 total matching documents
1. F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\SearchFiles.java
2. F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\IndexFiles.java
Press (q)uit or enter number to jump to a page.
Enter query:
问题还好解决。
注: -CP命令:-cp 参数后面是类路径,是指定给解释器到哪里找到你的.class文件。
百度有时候真是搜不出什么结果,这是就应该想google看齐。google的英文检索那真是没得说,而且国外资料确实要比国内全而且准。
Once you've gotten this far you're probably itching to go. Let's build an index! Assuming you've set your CLASSPATH correctly, just type:
java org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src
This will produce a subdirectory called index which will contain an index of all of the Lucene source code.
To search the index type:
java org.apache.lucene.demo.SearchFiles
You'll be prompted for a query. Type in a swear word and press the enter key. You'll see that the Lucene developers are very well mannered and get no results. Now try entering the word "string". That should return a whole bunch of documents. The results will
page at every tenth result and ask you whether you want more results.
我配置好CLASSPATH,可是结果如下:
D:\>java org.apache.lucene.demo.IndexFiles -docs F:\lib\lucene\lucene-3.5.0-src\
lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/dem
o/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)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: org.apache.lucene.demo.IndexFiles. Program will
exit.
百思不得其解。不知为何总出现这样的结果。后来改变了命令行的输入,问题解决,就这么个小小的错误,耗费了N个小时。
新输入的命令行:
D:\>java -cp C:\abc\lucene-core-3.5.0.jar;C:\abc\lucene-demo-3.5.0.jar org.apache.lucene.demo.IndexFiles -docs F:\lib\lu
cene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo
结果如下:
Indexing to directory 'index'...
adding F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\IndexFiles.java
adding F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\SearchFiles.java
407 total milliseconds
接着输入检索命令结果如下:
D:\>java -cp C:\abc\lucene-core-3.5.0.jar;C:\abc\lucene-demo-3.5.0.jar org.apache.lucene.demo.SearchFiles
Enter query:
String
Searching for: string
2 total matching documents
1. F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\SearchFiles.java
2. F:\lib\lucene\lucene-3.5.0-src\lucene-3.5.0\contrib\demo\src\java\org\apache\lucene\demo\IndexFiles.java
Press (q)uit or enter number to jump to a page.
Enter query:
问题还好解决。
注: -CP命令:-cp 参数后面是类路径,是指定给解释器到哪里找到你的.class文件。
百度有时候真是搜不出什么结果,这是就应该想google看齐。google的英文检索那真是没得说,而且国外资料确实要比国内全而且准。
相关文章推荐
- 运行"使用DroidPlugin实践应用的插件化"里面demo碰到的问题(附个人解决方案)
- Android在运行融云官方Demo时碰到的奇葩问题。
- dotlucene的searchDemo运行问题2
- 关于上传AppStore碰到Failed to locate or generate matching signing assets的问题
- 有关Lucene的问题(5):Lucene中的TooManyClause异常
- android MediaCodec的自己碰到的问题
- 有关Lucene的问题(7):用Lucene构建实时的索引
- 编写SSH框架碰到的问题
- 封装ios静态库碰到的一些问题(三)
- 编译eclair碰到java version "1.5.0_18"问题的解决
- SpringCloud(十四):Feign的demo之解决超时问题
- lucene版本升级到4.6.0以上之后使用mmseg4j分词器遇到的问题
- 新版Android studio导入微信支付和支付宝官方Demo问题解决大全
- Android学习笔记03:学习过程中碰到的一些问题及解决方法
- linux安装中碰到的问题
- 导入Android sdk demo到Eclipse出错问题解决
- ajax碰到请求url过长的问题! ajax中get和post的区别
- 更新CocoaPods碰到的问题及知识点
- 更新数据库碰到的字段添加问题
- cocos2dx xcoder 上传APP审核碰到的各种问题整理