fileStr.append(File.pathSeparator+(String)ce);
}
GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());
ClassLoader parentClassLoader = getClass().getClassLoader();
GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);
// update GUI components to account for the updated ScalaSci classpath
scalaExec.scalaLab.scalaLab.updateTree();
boolean compilationSucccess = true;
String tempFileName = "";
tempFileName = javaFile+".java"; // public classes and Java files should have the same name
String [] command = new String[6];
command[0] = "javac";
command[1] = "-cp";
command[2] = GlobalValues.jarFilePath+File.pathSeparator+GlobalValues.homeDir;
command[3] = "-d"; // where to place output class files
command[4] = SelectedFilePathOnly; // the path to save the compiled class files
command[5] = javaFile; // full filename to compile
String compileCommandString = command[0]+" "+command[1]+" "+command[2]+" "+command[3]+" "+command[4]+" "+command[5];
System.out.println("compileCommand Java= "+compileCommandString);
try {
Runtime rt = Runtime.getRuntime();
Process javaProcess = rt.exec(command);
// an error message?
StreamGobbler errorGobbler = new StreamGobbler(javaProcess.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new StreamGobbler(javaProcess.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
javaProcess.waitFor();
int rv = javaProcess.exitValue();
String commandString = command[0]+" "+command[1]+" "+command[2];
if (rv==0) {
System.out.println("Process: "+commandString+" exited successfully ");
generateScriptCodeButton.setEnabled(true);
statusAreaBottom.setText("Step5: You can proceed now to create a draft script that utilizes your Java-based ODE integrator");
}
else
System.out.println("Process: "+commandString+" exited with error, error value = "+rv);
} catch (IOException exio) {
System.out.println("IOException trying to executing "+command);
exio.printStackTrace();
}
catch (InterruptedException ie) {
System.out.println("Interrupted Exception trying to executing "+command);
ie.printStackTrace();
}
}
});
// Compile with the internal compiler
compileJavaInternalCompilerButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String currentWorkingDirectory = GlobalValues.workingDir;
JFileChooser chooser = new JFileChooser(currentWorkingDirectory);
int ret = chooser.showOpenDialog(ODEWizardFrame);
if (ret != JFileChooser.APPROVE_OPTION) {
return;
}
File f = chooser.getSelectedFile();
String javaFile=null;
try {
javaFile = f.getCanonicalPath();
}
catch (IOException ex) {
System.out.println("I/O Exception in getCanonicalPath");
ex.printStackTrace();
}
// extract the path specification of the generated Java class that implements the ODE solution method,
// in order to update the ScalaSci class path
String SelectedFileWithPath = f.getAbsolutePath();
String SelectedFilePathOnly = SelectedFileWithPath.substring(0, SelectedFileWithPath.lastIndexOf(File.separatorChar));
if (GlobalValues.ScalaSciClassPath.length()==0)
GlobalValues.ScalaSciClassPath=".";
if (GlobalValues.ScalaSciClassPath.indexOf(SelectedFilePathOnly)==-1) {
GlobalValues.ScalaSciClassPathComponents.add(0,SelectedFilePathOnly);
GlobalValues.ScalaSciClassPath = GlobalValues.ScalaSciClassPath+File.pathSeparator+SelectedFilePathOnly;
}
// update also the ScalaSciClassPath property
StringBuilder fileStr = new StringBuilder();
Enumeration enumDirs = GlobalValues.ScalaSciClassPathComponents.elements();
while (enumDirs.hasMoreElements()) {
Object ce = enumDirs.nextElement();
fileStr.append(File.pathSeparator+(String)ce);
}
GlobalValues.settings.setProperty("ScalaSciClassPath", fileStr.toString());
ClassLoader parentClassLoader = getClass().getClassLoader();
GlobalValues.extensionClassLoader = new ExtensionClassLoader(GlobalValues.ScalaSciClassPath, parentClassLoader);
// update GUI components to account for the updated ScalaSci classpath
scalaExec.scalaLab.scalaLab.updateTree();
String [] command = new String[11];