0

I was working on the Stanford sentiment classifier on windows. I wanted to retrain my own model, and here's how it was specified on the website:

java -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath train.txt -devPath dev.txt -train -model model.ser.gz

But this gave me the error:

could not find or load main class

But on changing it to java -cp "*" it worked.

Tim
  • 41,901
  • 18
  • 127
  • 145
  • See [SO](http://stackoverflow.com/questions/11922681/differences-between-java-cp-and-java-jar) – Markus Jun 05 '14 at 08:44
  • That question is about the difference between `java -jar` and `java -cp`. There is nothing about `-cp "*"` in that question or answers, so not a duplicate. – Erwin Bolwidt Jun 05 '14 at 09:59

3 Answers3

1

Class path entries can contain the basename wildcard character , which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. For example, the class path entry foo/ specifies all JAR files in the directory named foo. A classpath entry consisting simply of * expands to a list of all the jar files in the current directory.

From Oracle Docs

Terje
  • 1,753
  • 10
  • 13
0

-cp < class search path of directories and zip/jar files>

Search all jar and zip files in the current directory for a given class file

Tejas jain
  • 742
  • 7
  • 20
0

The cp flag specifies the classpath, that is, which other archives are to be considered for this program.

Usually, you'd give it a colon-separated list of jar files, but this particular example is a special case according to the documentation:

If -classpath and -cp are not used and CLASSPATH is not set, then the user class path consists of the current directory (.). As a special convenience, a class path element that contains a base name of * is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR. A Java program cannot tell the difference between the two invocations.

Note that the quotes are necessary, beause otherwise the shell would exapand it to all the files in the directory rather than only jar files.

rethab
  • 7,170
  • 29
  • 46