CORDA-1633 - Check Java version before launch (#4128)

This commit is contained in:
Tommy Lillehagen 2018-10-29 16:52:57 +00:00 committed by GitHub
parent ff9061b968
commit 199a20398c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,6 +54,7 @@ public class CordaCaplet extends Capsule {
@Override
protected ProcessBuilder prelaunch(List<String> jvmArgs, List<String> args) {
checkJavaVersion();
nodeConfig = parseConfigFile(args);
return super.prelaunch(jvmArgs, args);
}
@ -143,6 +144,14 @@ public class CordaCaplet extends Capsule {
}
}
private static void checkJavaVersion() {
String version = System.getProperty("java.version");
if (version == null || !version.startsWith("1.8")) {
System.err.printf("Error: Unsupported Java version %s; currently only version 1.8 is supported.\n", version);
System.exit(1);
}
}
private void requireCordappsDirExists(File dir) {
try {
if (!dir.mkdir() && !dir.exists()) { // It is unlikely to enter this if-branch, but just in case.