Problems encountered by Lucene running demo

Source: Internet
Author: User
I want to run the small part on the Lucene official website. Program , Classpath is configured, but still cannot run. The original information is as follows:

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 shoshould return a whole bunch of statements. the results will
Page at every tenth result and ask you whether you want more results.

After configuring classpath, the result is as follows:

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)
Cocould not find the main class: org. Apache. Lucene. Demo. indexfiles. program will
Exit.

Think twice about it. I don't know why this always happens. Later, it took n hours to change the command line input and solve the problem.
New command line:
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

The result is as follows:
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

Enter the SEARCH Command and the result is as follows:
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 events ents
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:

The problem is solved.

Note:-CP command: The-CP parameter is followed by a Class path, which specifies the interpreter where to find your. Class file.

Baidu sometimes cannot find any results, so we should try Google. Google's English search is really not to mention, and foreign information is indeed more comprehensive and accurate than in China.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.