Skip to content

Commit

Permalink
Improved the message when choosing between the regular java compiler …
Browse files Browse the repository at this point in the history
…and the ECJ compiler, which requires Java 11+
  • Loading branch information
flemming-n-larsen committed Sep 30, 2024
1 parent 852e223 commit 42d5688
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
import net.sf.robocode.io.FileUtil;
import net.sf.robocode.io.Logger;
import net.sf.robocode.manager.IVersionManagerBase;
import static net.sf.robocode.io.Logger.logError;
import static net.sf.robocode.io.Logger.logMessage;
import net.sf.robocode.ui.dialog.ConsoleDialog;
import net.sf.robocode.ui.dialog.WindowUtil;
import net.sf.robocode.util.JavaVersion;

import javax.swing.*;
import java.io.*;
import java.util.Objects;

import static net.sf.robocode.io.Logger.logError;
import static net.sf.robocode.io.Logger.logMessage;


/**
* @author Mathew A. Nelson (original)
Expand Down Expand Up @@ -101,8 +103,10 @@ public boolean configureCompiler(RobocodeEditor editor) {

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))",
"Robocode has found a working javac (Java Compiler) on this system.\nWould you like to use it?\n" +
"\n" +
"If you click No, Robocode will use the build-in Eclipse Compiler for Java (ECJ),\n" +
"which requires Java 11 or newer.",
"Confirm javac",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE);
Expand All @@ -111,6 +115,17 @@ public boolean configureCompiler(RobocodeEditor editor) {
javacOK = false;
}
}

if (!javacOK) {
if (JavaVersion.getJavaMajorVersion() < 11) {
JOptionPane.showMessageDialog(editor, "Eclipse Compiler for Java (ECJ) requires\n" +
"Java 11 or newer to run.\n" +
"Please upgrade Java 11 or newer.",
"Error", JOptionPane.ERROR_MESSAGE);

return false; // compilerOK = false
}
}

if (!javacOK) {
compilerName = "Eclipse Compiler for Java (ECJ)";
Expand Down

0 comments on commit 42d5688

Please sign in to comment.