我用Java编写了一个程序。但是当我编译这个程序时,它会显示错误 如何解决这个问题呢? 该程序的源代码是:
import org.rosuda.JRI.Rengine;
public class JavaGDExample1 {
public static void main(String[] args) {
Rengine re;
String[] dummyArgs = new String[1];
dummyArgs[0] = "--vanilla";
re = new Rengine(dummyArgs, false, null);
re.eval("library(JavaGD)");
// This is the critical line: Here, we tell R that the JavaGD() device that
// it is supposed to draw to is implemented in the class MyJavaGD. If it were
// in a package (say, my.package), this should be set to
// my/package/MyJavaGD1.
re.eval("Sys.putenv('JAVAGD_CLASS_NAME'='MyJavaGD1')");
re.eval("JavaGD()");
re.eval("plot(c(1,5,3,8,5), type='l', col=2)");
re.end();
}
}
显示此错误
No symbol for REngine
请回复
答案 0 :(得分:1)
我假设您在尝试编译时遇到“找不到符号”错误消息。在这种情况下,这意味着您尚未将相关的JAR文件添加到类路径中。
您可以按如下方式指定类路径。
java -cp< PATH_TO_YOUR_LIB> < YOUR_CLASSES>
如果您使用的是IDE,则必须将这些JAR文件作为库添加到其中。