1

This question seems to have been answered a few times (What does "Could not find or load main class" mean? and https://stackoverflow.com/a/16208709/2771315) but for some reason none of the shared methods are working.

What I've done so far.

1) Navigated to the directory containing the CoreNLP source files in terminal: ~/Downloads/CoreNLP-master/src

2) Selected one of the packages as a test case e.g. executed the command java -cp "*" -mx5g edu.stanford.nlp.sentiment.SentimentPipeline -file foo.txt (as per the docs, http://nlp.stanford.edu/sentiment/code.html)

I've tried variations of the above by altering the classpath -cp condition and setting it using set CLASSPATH = $CLASSPATH=~/Downloads/CoreNLP-master/src but can't seem to get a result. Does anyone know what I'm doing wrong? If I were to hazard a guess, I think that there is something wrong with the classpath but I'm not sure what.

Community
  • 1
  • 1
Black
  • 4,483
  • 8
  • 38
  • 55
  • The issue is that you're using a later release than the 3.3.1 release that's supported https://github.com/xissy/node-stanford-simple-nlp/issues/15 Current version on the Stanford website is is 3.6.0. – buley Jan 15 '16 at 05:10

3 Answers3

4

The classpath should point to the classes, not the source files. If you're using the GitHub version of the code, you can set the classpath to be:

-cp ~/Downloads/CoreNLP-master/classes:/path/to/corenlp/models.jar

You can find the most recent version of the CoreNLP models at: http://nlp.stanford.edu/software/stanford-corenlp-models-current.jar (warning: >200MB file)

If you have one of the corenlp releases, you should set your classpath to:

-cp /path/to/corenlp.jar:/path/to/corenlp/models.jar

For example:

export CLASSPATH=stanford-corenlp-3.9.1.jar:stanford-corenlp-3.9.1-models.jar

Both the corenlp jar and the models jar should show up in the zipped release of the code (e.g., from http://nlp.stanford.edu/software/corenlp.shtml)

A_Matar
  • 2,210
  • 3
  • 31
  • 53
Gabor Angeli
  • 5,729
  • 1
  • 18
  • 29
  • Hi Gabor, thanks for your reply. When I use the GitHub version of the code, the `~/Downloads/CoreNLP-master/classes` seems to be empty. As a result, I've downloaded the CoreNLP 3.5.0 release. I've tried the following, `java -cp ~/Downloads/stanford-corenlp-full-2014-10-31/stanford-corenlp-3.5.0.jar:~/Downloads/stanford-corenlp-full-2014-10-31/stanford-corenlp-3.5.0-models.jar edu.stanford.nlp.sentiment.Evaluate edu/stanford/nlp/models/sentiment/sentiment.ser.gz test.txt` which is another example provided on http://nlp.stanford.edu/sentiment/code.html. Is my command above correct? – Black Jan 15 '15 at 22:44
  • That command looks correct. For the Github version of the code, you first have to compile the project with ant ("$ ant"). If you get other classes which are not found, you may need to include various other libraries included in the release (see https://github.com/stanfordnlp/CoreNLP/tree/master/lib -- xom, jodatime, and jollyday are the cost common ones). – Gabor Angeli Jan 16 '15 at 00:34
  • Using the non-Github version I get a `NoClassDefFoundError` exception on `org/ejml/simple/SimpleBase`. Looking through `org/ejml/simple/` I can see the the `SimpleBase` class exists. I've replaced the `ejml-0.23.jar` from the library repository you suggested but to no avail. Do you know why this is occurring? – Black Jan 18 '15 at 07:37
  • Are you including ejml-0.23.jar in your classpath? – Gabor Angeli Jan 18 '15 at 18:46
  • `ejml-0.23`.jar is in `~/Downloads/stanford-corenlp-full-2014-10-31/` so maybe not. I've tried `java -cp ~/Downloads/stanford-corenlp-full-2014-10-31/stanford-corenlp-3.5.0.jar:~/Downlo‌​ads/stanford-corenlp-full-2014-10-31/* edu.stanford.nlp.sentiment.Evaluate edu/stanford/nlp/models/sentiment/sentiment.ser.gz test.txt` to include all the `.jar` files in CoreNLP but it doesn't seem to work. Would you know how to add it to the classpath? – Black Jan 19 '15 at 00:17
  • Maybe try adding the jar files explicitly to the classpath? But, in any event, this seems to be a separate Java question on how to include jars in a classpath, rather than anything CoreNLP specific. – Gabor Angeli Jan 19 '15 at 02:00
  • I've tried `java -cp ~/Downloads/stanford-corenlp-full-2014-10-31/stanford-corenlp-3.5.0.jar:~/Downlo‌​‌​ads/stanford-corenlp-full-2014-10-31/ejml-0.23.jar:~/Downlo‌​ads/stanford-corenlp-full-2014-10-31/stanford-corenlp-3.5.0-models.jar edu.stanford.nlp.sentiment.Evaluate edu/stanford/nlp/models/sentiment/sentiment.ser.gz test.txt` with explicit addition of `ejml-0.23.jar` but it doesn't seem to help. Yes, you're right. But I feel that this could be quite useful to other CoreNLP users you may experience the same issues when they follow the documentation provided. – Black Jan 19 '15 at 03:40
2

This worked perfectly fine for me.

java -cp "../*" -mx1g edu.stanford.nlp.sentiment.SentimentPipeline -file test.txt 

Run this command while you are in the classes directory.

Belphegor
  • 4,456
  • 11
  • 34
  • 59
0

You are trying to run the program, instead of compiling it.

Fernando Mendez
  • 2,559
  • 1
  • 10
  • 7