Here is my original java code with method of "performCurveFitting" method
public static String performCurveFitting(Double[] conc, Double[] resp, Double classificationSD, Double minYrange) {
CurveFittingService fittingService = new CurveFittingServiceImpl();
FittingResult fittingResult = fittingService.doFit(conc, resp, classificationSD, minYrange);
// Convert the fitting result to a String representation
return fittingResult.toString(); // Assuming FittingResult has overridden toString() method
}
In R code,
I did the following commands with no errors
.jinit('.')
.jaddClassPath('inst/java/curve-fitting.jar')
curvefit <- .jnew('gov/nih/ncats/ifx/qhts/curvefitting/CurveClassFit')
.DollarNames(curvefit)
However, when I tested the method using the following command
.jcall(curvefit, returnSig = "Ljava/lang/String;", method = "performCurveFitting", c(5.5707525685E-10, 4.5123095805E-8, 1.2183235867E-6, 3.2894736842E-5),c(2,4,6,100), 5, 10)
I got this error
Error in .jcall(curvefit, returnSig = "Ljava/lang/String;", method = "performCurveFitting", : method performCurveFitting with signature ([D[DDD)Ljava/lang/String; not found
How can I fix this error?
Thank you!
The reason here is that your code looks for a method with
doubleand you are defining it withDoubleTry using
doubleinstead. Should be visible to yourRcode.With
javapcommand you can see the exact signature of your code. As you can see. Your signature is:while your
Rcode is looking for:Most probably,
Ruses small Java'sdoubleswhenever you are usingRdoubles passed toJava.