首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >java.lang.NoClassDefFoundError: java-ee中的rcaller/RCaller

java.lang.NoClassDefFoundError: java-ee中的rcaller/RCaller
EN

Stack Overflow用户
提问于 2016-07-15 17:15:28
回答 0查看 148关注 0票数 0

我正在尝试使用R caller将回归R代码集成到我的j2ee项目中。我的数据源来自mysql数据库。所以我使用RMYSQL作为包。我的代码在java项目下工作得很好,但是当我把它移到backing类中时,它抛出了一个异常:java.lang.NoClassDefFoundError: rcaller/RCaller

在maven dependency中,Rcaller只有2.8版本。我需要2.5版本,所以我已经将它添加到手动构建路径中。

支持bean的方法是:

代码语言:javascript
运行
复制
try {

       RCaller caller = new RCaller();
       RCode code = new RCode();  

       caller.setRscriptExecutable("Rscript.exe");
       code.clear();
       caller.setRCode(code);

       code.R_require("RMySQL");
       code.R_require("rpart");


       code.addRCode("mydb= dbConnect(MySQL(),user='root',password='root',dbname='db',host='localhost')"); 
       code.addRCode("rs= dbSendQuery(mydb,'select * from table')"); 
       code.addRCode("data = fetch(rs,n=-1)");  
       code.addRCode("data= data[data[['cred']]>0,]");  
       code.addRCode("data$navig <- ifelse(data$navig == 'Chrome',1,ifelse(data$navig == 'Firefox',2,ifelse(data$navig == 'Android',3,ifelse(data$navig == 'iPhone',4,9))))");  
       code.addRCode("data$rate =as.factor(data$rate)");  
       code.addRCode("ad.apprentissage= rpart(rate~vqs+ibt+tbt+bf+n+down+ping, data=data,minsplit = 7)");  
       code.addRCode("predArbreDecision=predict(ad.apprentissage,newdata=data,type='class') ");  
       code.addRCode("table(data$rate, predArbreDecision)");  


       File file = code.startPlot();
      // code.addRCode("ggplot(df, aes(x, y)) + geom_point() + geom_smooth(method='lm') + ggtitle('y = f(x)')");
code.addRCode("plot(ad.apprentissage,main='Arbre de décision de la vidéo Streaming')");
code.addRCode("text(ad.apprentissage)");
       caller.runOnly();
       ImageIcon ii = code.getPlot(file);
       code.showPlot(file);

   } catch (Exception e) {
       System.out.println(e.toString());
   } 

为了在jsf页面中显示图形,我按如下方式调用了该函数:

代码语言:javascript
运行
复制
 #{video_R_IntegrationBean.Test3()} 
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38392311

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档