`
单眼皮大娘
  • 浏览: 112785 次
  • 性别: Icon_minigender_2
  • 来自: 上海
社区版块
存档分类
最新评论

Building and Installing the Basic Demo

阅读更多
想运行一下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 Embedded Linux Systems, 2nd

    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 ...

    Building Web Applications with Python and Neo4j(PACKT,2015)

    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 ...

    Exam Ref 70-410: Installing and Configuring Windows Server 2012 R2

    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 ...

    Learning Android: Develop Mobile Apps Using Java and Eclipse(第二版)

    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

    Basic-Internet-Security 一本关于系统安全的书籍pdf

    驱动 Intel

    Intel 的驱动 This document contains the following sections: 1. Overview ...10. Verifying Installation of the Software and Identifying the Software Version Number 11. Troubleshooting

    OpenStack.Networking.Essentials.1785283278

    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...

    The Busy Coders Guide to Android Development最终版2019

    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...

    Installing the Zend Debugger PDF

    标题中的“Installing the Zend Debugger PDF”实际上指的是一个关于如何安装Zend Debugger的PDF文档的安装指南。Zend Debugger是一款功能强大的PHP扩展,它主要用于在开发过程中进行代码调试,通过将服务器端的调试...

    Arduino by Example

    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 ...

    linux kernel in a nutshell

    The Linux kernel is the core component of the Linux operating system, responsible for managing system resources and providing basic services to applications. It acts as an interface between hardware ...

    CommonsWare.The.Busy.Coders.Guide.to.Android.Development.Version.8.2.2017

    Android, the next-generation open mobile platform from Google and the Open Handset Alliance, is poised to become a significant player in the mobile device market. The Android platform gives developers...

    OpenStack Networking Essentials

    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 and Configuring Openfiler with DRBD and Heartbeat

    Installing and Configuring Openfiler with DRBD and Heartbeat

    Installing And Configuring Windows Server 2012 Exam Ref 70-410

    根据提供的文件信息,本书《Installing and Configuring Windows Server 2012 Exam Ref 70-410》是一本针对Microsoft认证考试70-410的专业辅导教材。本书由Craig Zacker编写,并由Microsoft Press出版。以下是本书中...

    XviD源代码

    - xvidcore/doc/INSTALL: building and installing instructions. 3) Licensing: - XviD is licensed as a whole under the terms of the XviD license described in the file LICENSE This is true for all ...

    Getting-Started-with-Julia-Programming

    Chapter 3, Functions, explains why functions are the basic building blocks of Julia, and how to effectively use them. Chapter 4, Control Flow, shows Julia’s elegant control constructs, how to perform...

    Beginning iOS 7 Development: Exploring the iOS SDK

    The book starts with the basics, walking through the process of downloading and installing Xcode and the iOS 7 SDK, and then guides you though the creation of your first simple application. ...

Global site tag (gtag.js) - Google Analytics