0

I'm newbie to Java. I have read all the documentations regarding specifing the classpath. But I'm still confused about my case. I'm trying to use the BuildIndex command that is part of semantic package, specifically this example,

java pitt.search.semanticvectors.BuildIndex -luceneindexpath $INDEX_MADE_ABOVE.

in here

The source of how to use the class is here https://github.com/semanticvectors/semanticvectors/wiki/InstallationInstructions#to-build-and-search-a-model

I'm trying to specify the classpath like:

java cp- {classpath} pitt.search.semanticvectors.BuildIndex -luceneindexpath $INDEX_MADE_ABOVE.
in here

But I'm not sure what the class path should be here. . The command line should have a class path, but thinking it should not be related to my project, it's part of the semantic vectors package. Do I need to clone that? its source code from the package here https://github.com/semanticvectors/semanticvectors/blob/master/src/main/java/pitt/search/semanticvectors/BuildIndex.java..

My trials was using the path of my project as the picture but didn't work. Another trial was using -jar jarName ,, got the same error: Could not find or load main class pitt.search.semanticvectors.BuildIndex. I appreciate the help as I'm confused and new to this.

1 Answer 1

0

In Java, classpath is the path pointing to either the directory or the jar file where your compiled java class files are located.

In your project, the class pitt.search.semanticvectors.BuildIndex is located in the jar file C:\Users\{yourusername}\Downloads\semanticvectors-5.8.jar. Therefore, the classpath is C:\Users\{yourusername}\Downloads\semanticvectors-5.8.jar.

Try something like

java -cp C:\Users\{yourusername}\Downloads\semanticvectors-5.8.jar pitt.search.semanticvectors.BuildIndex -luceneindexpath $INDEX_MADE_ABOVE

I think you mistyped cp- instead of -cp.

For more details how to use classpath, please refer to Java SE Documentation

2
  • I was using jar instead of -cp,, I thought jar is what it should be used beside the jar file path,,, by the way,, what is the directory could be here in this case?
    – Lelo
    Jul 27, 2016 at 21:16
  • To execute a Java class (in your case pitt.search.semanticvectors.BuildIndex), Java must know where the class is located. If it is NOT located in the global classpath, then you need to specify the classpath in the command line parameter (´-cp´). Normally, compiled code are packed in a jar file (basically just a zip file). But if the compiled code are not packed in a jar file, it will be in a certain directory (Take a look at the directory bin in your project, Eclipse will put all compiled java code there)
    – anhquan
    Jul 27, 2016 at 21:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.