return FileUtil.quoteFileName(javalib);
}
public boolean configureCompiler(RobocodeEditor editor) {
ConsoleDialog console = new ConsoleDialog(editor, "Setting up compiler", false);
console.setSize(500, 400);
console.getOkButton().setEnabled(false);
console.setText("Please wait while Robocode sets up a compiler for you...\n\n");
WindowUtil.centerShow(editor, console);
console.append("Setting up compiler\n");
console.append("Java home is " + System.getProperty("java.home") + "\n\n");
String compilerName = "Java Compiler (javac)";
String compilerBinary = "javac";
String compilerOptions = "-deprecation -g -source 1.6 -encoding UTF-8";
boolean javacOK = testCompiler(compilerName, compilerBinary, console);
boolean ecjOK = false;
if (javacOK) {
int rc = JOptionPane.showConfirmDialog(editor,
"Robocode has found a working javac (Java Compiler) on this system.\nWould you like to use it?\n"
+ "(If you click No, Robocode will use the build-in Eclipse Compiler for Java (ECJ))",
"Confirm javac",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (rc == JOptionPane.NO_OPTION) {
javacOK = false;
}
}
if (!javacOK) {
compilerName = "Eclipse Compiler for Java (ECJ)";
compilerBinary = "java -cp compilers/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main";
ecjOK = testCompiler("Eclipse Compiler for Java (ECJ)", compilerBinary, console);
}
boolean compilerOK = javacOK || ecjOK;
if (compilerOK) {
console.append("\nCompiler has been set up successfully.\nClick OK to continue.\n");
} else {
final String errorText = "Could not set up a working compiler for Robocode.\n"
+ "Please consult the console window for errors.\n\n"
+ "For help with this, please post to Help forum here:\n"
+ "http://sourceforge.net/projects/robocode/forums/forum/116459";
console.append("\nUnable to set up a working compiler for Robocode.\n");
JOptionPane.showMessageDialog(editor, errorText, "Error", JOptionPane.ERROR_MESSAGE);
compilerBinary = "";
compilerOptions = "";
}
getCompilerProperties().setRobocodeVersion(ContainerBase.getComponent(IVersionManagerBase.class).getVersion());
getCompilerProperties().setCompilerBinary(compilerBinary);
getCompilerProperties().setCompilerOptions(compilerOptions);
getCompilerProperties().setCompilerClasspath(COMPILER_CLASSPATH);
saveCompilerProperties();
console.scrollToBottom();
console.getOkButton().setEnabled(true);
return compilerOK;
}