Skip to content

Commit 57a08ad

Browse files
author
hako
committed
Version 2.5
1 parent f40d5b9 commit 57a08ad

7 files changed

Lines changed: 53 additions & 41 deletions

File tree

RCaller/.RData

-3.43 KB
Binary file not shown.

RCaller/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>rcaller</groupId>
66
<artifactId>RCaller</artifactId>
7-
<version>2.4-SNAPSHOT</version>
7+
<version>2.5</version>
88
<packaging>jar</packaging>
99

1010
<name>RCaller</name>
Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
/*
22
*
3-
RCaller, A solution for calling R from Java
4-
Copyright (C) 2010-2014 Mehmet Hakan Satman
3+
RCaller, A solution for calling R from Java
4+
Copyright (C) 2010-2014 Mehmet Hakan Satman
55
6-
This program is free software: you can redistribute it and/or modify
7-
it under the terms of the GNU Lesser General Public License as published by
8-
the Free Software Foundation, either version 3 of the License, or
9-
any later version.
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Lesser General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
any later version.
1010
11-
This program is distributed in the hope that it will be useful,
12-
but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
GNU General Public License for more details.
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
1515
16-
You should have received a copy of the GNU Lesser General Public License
17-
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
You should have received a copy of the GNU Lesser General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*
1919
*
2020
* Mehmet Hakan Satman - mhsatman@yahoo.com
@@ -23,36 +23,42 @@
2323
* Please visit the blog page with rcaller label:
2424
* http://stdioe.blogspot.com.tr/search/label/rcaller
2525
*/
26-
2726
package rcaller;
2827

2928
import graphics.DefaultTheme;
3029
import graphics.GraphicsTheme;
3130

3231
public class Globals {
3332

34-
public static String cranRepos = "http://cran.r-project.org";
35-
public static String RScript_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe";
36-
public static String RScript_Linux = "/usr/bin/Rscript";
37-
public static String Rscript_current;
38-
public static String R_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\R.exe";
39-
public static String R_Linux = "/usr/bin/R";
40-
public static String R_current;
41-
42-
public static GraphicsTheme theme = new DefaultTheme();
43-
44-
public final static String version = "RCaller 2.0";
45-
public final static String about = "Author: Mehmet Hakan Satman - mhsatman@yahoo.com";
46-
public final static String licence = "LGPL v3.0";
47-
48-
49-
public static void detect_current_rscript() {
50-
if (System.getProperty("os.name").contains("Windows")) {
51-
Rscript_current = RScript_Windows;
52-
R_current = R_Windows;
53-
} else {
54-
Rscript_current = RScript_Linux;
55-
R_current = R_Linux;
56-
}
57-
}
33+
public static String cranRepos = "http://cran.r-project.org";
34+
public static String RScript_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe";
35+
public static String RScript_Linux = "/usr/bin/Rscript";
36+
public static String Rscript_current;
37+
public static String R_Windows = "C:\\Program Files\\R\\R-3.0.2\\bin\\R.exe";
38+
public static String R_Linux = "/usr/bin/R";
39+
public static String R_current;
40+
41+
public static GraphicsTheme theme = new DefaultTheme();
42+
43+
public final static String version = "RCaller 2.0";
44+
public final static String about = "Author: Mehmet Hakan Satman - mhsatman@yahoo.com";
45+
public final static String licence = "LGPL v3.0";
46+
47+
public static void detect_current_rscript() {
48+
if (System.getProperty("os.name").contains("Windows")) {
49+
Rscript_current = RScript_Windows;
50+
R_current = R_Windows;
51+
} else {
52+
Rscript_current = RScript_Linux;
53+
R_current = R_Linux;
54+
}
55+
}
56+
57+
public static boolean isWindows() {
58+
if (System.getProperty("os.name").contains("Windows")) {
59+
return (true);
60+
} else {
61+
return (false);
62+
}
63+
}
5864
}

RCaller/src/main/java/rcaller/RCaller.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,12 @@ public void StopRCallerOnline() {
332332
try {
333333
process.getOutputStream().write("q(\"no\")\n".getBytes());
334334
process.getOutputStream().flush();
335+
process.getOutputStream().close();
335336
} catch (Exception e) {
336337
}
337-
process.destroy();
338+
if(Globals.isWindows()){
339+
process.destroy();
340+
}
338341
}
339342
}
340343

RCaller/src/test/java/rcaller/GridCapTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public class GridCapTest {
1010
public void GridCapTest(){
1111
RCaller caller = new RCaller();
1212
RCode code = new RCode();
13-
caller.setRscriptExecutable("C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe");
13+
Globals.detect_current_rscript();
14+
caller.setRscriptExecutable(Globals.Rscript_current);
1415
code.R_require("grid");
1516
code.addRCode("dev.new(width=.5, height=.5)");
1617
code.addRCode("grid.rect()");

RCaller/src/test/java/rcaller/RunOnlineTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ public void testMatrixOnline() {
4242
double mad = rcaller.getParser().getAsDoubleArray("result")[0];
4343
System.out.println("mad: " + mad);
4444

45+
System.out.println("Deleting temp files:");
4546
rcaller.deleteTempFiles();
47+
System.out.println("Stopping RCaller online");
4648
rcaller.StopRCallerOnline();
4749
}
4850

RCaller/src/test/java/rcaller/matrix/RealMatrixTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static void MyAfterClass() {
2222

2323
public RealMatrixTest() {
2424
Globals.detect_current_rscript();
25-
pathToR = Globals.R_Windows;
25+
pathToR = Globals.R_current;
2626
if (rm == null) {
2727
rm = new RealMatrix(pathToR, "MyMatrix");
2828
}

0 commit comments

Comments
 (0)