java 斯坦福 NLP:找不到主类错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27955569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Stanford-NLP: Could not find main class error
提问by Black
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.
这个问题似乎已经回答了几次(“找不到或加载主类”是什么意思?和https://stackoverflow.com/a/16208709/2771315)但由于某种原因,共享方法都不起作用.
What I've done so far.
到目前为止我所做的。
1) Navigated to the directory containing the CoreNLP source files in terminal: ~/Downloads/CoreNLP-master/src
1)导航到终端中包含CoreNLP源文件的目录: ~/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)
2)选择其中一个包作为测试用例,例如执行命令java -cp "*" -mx5g edu.stanford.nlp.sentiment.SentimentPipeline -file foo.txt
(根据文档,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.
我已经通过更改类路径-cp
条件并使用设置它来尝试上述变体,set CLASSPATH = $CLASSPATH=~/Downloads/CoreNLP-master/src
但似乎无法获得结果。有谁知道我做错了什么?如果我冒险猜测,我认为类路径有问题,但我不确定是什么。
回答by Gabor Angeli
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:
类路径应该指向类,而不是源文件。如果您使用的是 GitHub 版本的代码,则可以将类路径设置为:
-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)
您可以在以下位置找到 CoreNLP 模型的最新版本:http: //nlp.stanford.edu/software/stanford-corenlp-models-current.jar (警告:>200MB 文件)
If you have one of the corenlp releases, you should set your classpath to:
如果您有 corenlp 版本之一,则应将类路径设置为:
-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)
corenlp jar 和模型 jar 都应该出现在代码的压缩版本中(例如,来自http://nlp.stanford.edu/software/corenlp.shtml)
回答by user2481205
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.
在 classes 目录中运行此命令。
回答by Fernando Mendez
You are trying to run the program, instead of compiling it.
您正在尝试运行该程序,而不是编译它。