KristianMedK
KristianMedK

Reputation: 1841

Setting lucene jar files in java classpath

I'm new to lucene and is having trouble getting started.

Following the beginners guide at http://lucene.apache.org/java/3_3_0/demo.html i'm trying to set the classpath, copying the syntax from http://download.oracle.com/javase/1.3/docs/tooldocs/win32/classpath.html.

this is what I entered in the command line:

C:\Users\k>java -classpath C:\Users\k\Downloads\lucene-3.3.0\contrib\demo\lucene-demo-3.3.0.jar;C:\Users\k\Downloads\lucene-3.3.0\lucene-core-3.3.0.jar

It returns a list of options usable with the java keyword.

What am i doing wrong ?

Upvotes: 1

Views: 4922

Answers (2)

Tim Sparg
Tim Sparg

Reputation: 3304

You need something along the lines of

C:\Users\k>java -classpath C:\Users\k\Downloads\lucene-3.3.0\contrib\demo\lucene-demo-3.3.0.jar;C:\Users\k\Downloads\lucene-3.3.0\lucene-core-3.3.0.jar org.apache.lucene.demo.IndexFiles -docs {path-to-lucene}/src

It looks like you set the classpath correctly, all you needed to do after that was org.apache.lucene.demo.IndexFiles which tells the JVM which is the main class of the application and -docs {path-to-lucene}/src is an argument passed into the lucene demo.

Upvotes: 4

Harry Joy
Harry Joy

Reputation: 59660

The command you are using is not for setting class path. It is the java command used to run java class file. You are providing it a class path arguments which determines from where to load class files.

To set classpath use this command on windows:

set CLASSPATH=classpath1;classpath2...

So if you want to still use java command with -classpath argument then specify a class name at the end of command which is the class going to be run like

C:\Users\k>java -classpath C:\Users\k\Downloads\lucene-3.3.0\contrib\demo
   \lucene-demo-3.3.0.jar;C:\Users\k\Downloads\lucene-3.3.0\
    lucene-core-3.3.0.jar MyClassName

Upvotes: 2

Related Questions