Skip to content

Commit 0b58cbf

Browse files
committed
add: hint of current jre version
1 parent 645ebff commit 0b58cbf

File tree

1 file changed

+18
-3
lines changed
  • src/main/java/cn/rocket/assaignmark/cmd

1 file changed

+18
-3
lines changed

src/main/java/cn/rocket/assaignmark/cmd/Main.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,30 @@ public class Main {
2121
* @param args 外部传入参数
2222
*/
2323
public static void main(String[] args) {
24+
String jreVer = System.getProperty("java.runtime.version");
25+
try {
26+
jreVer = jreVer.substring(0, jreVer.indexOf('.', 2));
27+
} catch (StringIndexOutOfBoundsException e) {
28+
LOGGER.warn("Unknown JRE version! Try to run with JRE 1.11. Unexpected errors may bo emitted.");
29+
jreVer = "1.11";
30+
}
2431
if (args == null || args.length == 0) {
25-
if (!System.getProperty("java.runtime.version").startsWith("1.8.")) {
32+
if (jreVer.equals("1.8")) {
33+
LOGGER.info("Running in JRE 1.8. Suitable.");
34+
} else {
35+
LOGGER.fatal("Running in JRE " + jreVer + "! Please run this program in 1.8.");
2636
LOGGER.fatal("要使用图形化界面,只能使用java8!请使用java8启动此程序,或下载用于java17的版本(如果有)");
2737
System.exit(1);
2838
}
2939
Launcher.launchSelf();
30-
return;
40+
} else {
41+
if (jreVer.equals("1.8"))
42+
LOGGER.info("Running in JRE 1.8. Suitable");
43+
else
44+
LOGGER.warn("Running in JRE " + jreVer + ". I do not guarantee no unexpected errors. The program was " +
45+
"written in 1.8.");
46+
Processor.main(args);
3147
}
32-
Processor.main(args);
3348
}
3449

3550
/**

0 commit comments

Comments
 (0)