想运行一下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的英文检索那真是没得说,而且国外资料确实要比国内全而且准。
分享到:
相关推荐
Building and installing Cluster Glue from source 3.1.1. Cluster Glue build prerequisites 3.1.2. Downloading Cluster Glue sources 3.1.3. Building Cluster Glue 3.1.4. Building Packages 3.2. ...
Installing the Google Search Appliance.pdf Installing the Google Search Appliance.pdf Installing the Google Search Appliance.pdf Installing the Google Search Appliance.pdf Installing the Google Search...
building, and installing a target-specific kernel * Creating a complete target root filesystem * Setting up, manipulating, and using solid-state storage devices * Installing and configuring a ...
Installing the Zend Debugger PDF
You will begin with licensing and installing Neo4j, learning the fundamentals of Cypher as a graph query language, and exploring Cypher optimizations. You will discover how to integrate with various ...
Compiling and Installing
Designed for experienced IT professionals ready to advance their status, Exam Ref focuses on the critical thinking and decision making acumen needed for success at the MCSA level. Focus on the ...
Coverage of 100% of all exam objectives in this Study Guide means you’ll be ready for: Comparing and contrasting... Installing and configuring equipment in the appropriate location using best practices
Module 1 - SCVMM 2012 R2 Introducing and Installing
Chapter 4 Installing and Beginning Use of Android Tools Installing Java Development Kit Installing the Android SDK Hello World! Anatomy of an Android Project Drawable Resources Building the Project ...
Basic-Internet-Security 一本关于系统安全的书籍pdf
Intel 的驱动 This document contains the following sections: 1. Overview ...10. Verifying Installation of the Software and Identifying the Software Version Number 11. Troubleshooting
mcsa考试题库。exam:70-410 。Installing and Configuring Windows Server 2012 R2
Ch 2: Developing, Installing, and Testing First App Ch 3: Making Apps More Interactive through Data Input Ch 4: Making Apps Do Significant Computing Ch 5: A Menu-Driven App to Monitor Important ...
STK-Disk913x-Installing the ArrayGUIde Utiity Revision 1.6 on an
Events, the Clipboard, and Drag and Drop Chapter 11. Custom Widgets Chapter 12. Item-Based Graphics Chapter 13. Rich Text and Printing Chapter 14. Model/View Programming . Chapter 15. Databases Part...
Tutorial #1 - Installing the Tools Android and Projects Tutorial #2 - Creating a Stub Project Getting Around Android Studio Contents of Android Projects Introducing Gradle and the Manifest Tutorial #3...
The OpenStack Networking API offers users the ability to create and manage both basic and complex network architectures that blend the virtual and physical network infrastructure. This book kicks off...
Installing the Windows Phone SDK and the XNA framework. Drawing 2D and 3D graphics. Mixing 2D and 3D graphics. Drawing 2D and 3D animations. Playing 2D and 3D sound. Playing songs. Handling touch ...
beginning with acquiring the necessary components and installing the software to write your frst program and see the magic begin. Chapter 2, Digital Ruler, brings in commonly used Arduino-friendly ...