我想使用 execvp 调用 java 来执行一个函数,如下面的代码:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main()
{
char* const argv[]= {
"-mx300m","-cp","\'stanford-postagger.jar:/root/NLP/postagger/:.\'",
"edu.stanford.nlp.tagger.maxent.MaxentTagger",
" -model","/root/NLP/postagger/models/english-bidirectional-distsim.tagger",
"-textFile","/root/NLP/postagger/sample-input.txt",
NULL
};
execvp("java",argv);
return 0;
}
但发生错误:
Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/tagger/maxent/MaxentTagger
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.tagger.maxent.MaxentTagger
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: edu.stanford.nlp.tagger.maxent.MaxentTagger. Program will exit.
谁能帮我解决这个问题?非常感谢 :)