Alka
Alka

Reputation: 1

for connection of R and Java

I have written a program in Java. But when I compile this program it shows an error How to solve this problem? the source code of the program is:

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();
  }
} 

it shows this error

No symbol for REngine

please reply

Upvotes: 0

Views: 313

Answers (1)

Yohan Liyanage
Yohan Liyanage

Reputation: 7000

I assume that you are getting 'cannot find symbol' error message when you attempt to compile this. In that case, it means that you have not added the relevant JAR file into your classpath.

You can specify the classpath as follows.

java -cp <PATH_TO_YOUR_LIB> <YOUR_CLASSES>

If you are using an IDE, you will have to add these JAR files as libraries into it.

Upvotes: 1

Related Questions