diff --git a/build.gradle b/build.gradle index a7b5e45a840..75fe1c3006a 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ configurations { } javafx { - version = "15" + version = "15.0.1" modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.web', 'javafx.swing' ] } diff --git a/src/main/java/org/jabref/gui/help/AboutDialogViewModel.java b/src/main/java/org/jabref/gui/help/AboutDialogViewModel.java index c5528b97e18..85e189019ff 100644 --- a/src/main/java/org/jabref/gui/help/AboutDialogViewModel.java +++ b/src/main/java/org/jabref/gui/help/AboutDialogViewModel.java @@ -58,8 +58,8 @@ public AboutDialogViewModel(DialogService dialogService, ClipBoardManager clipBo authors.set(buildInfo.authors); license.set(Localization.lang("License") + ":"); changelogUrl = buildInfo.version.getChangelogUrl(); - versionInfo = String.format("JabRef %s%n%s %s %s %nJava %s", buildInfo.version, BuildInfo.OS, - BuildInfo.OS_VERSION, BuildInfo.OS_ARCH, BuildInfo.JAVA_VERSION); + versionInfo = String.format("JabRef %s%n%s %s %s %nJava %s %nJavaFX %s", buildInfo.version, BuildInfo.OS, + BuildInfo.OS_VERSION, BuildInfo.OS_ARCH, BuildInfo.JAVA_VERSION, BuildInfo.JAVAFX_VERSION); } public String getDevelopmentVersion() { diff --git a/src/main/java/org/jabref/logic/util/BuildInfo.java b/src/main/java/org/jabref/logic/util/BuildInfo.java index 9e7f3e258e5..54239dfc106 100644 --- a/src/main/java/org/jabref/logic/util/BuildInfo.java +++ b/src/main/java/org/jabref/logic/util/BuildInfo.java @@ -16,6 +16,8 @@ public final class BuildInfo { public static final String OS_VERSION = System.getProperty("os.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); public static final String OS_ARCH = System.getProperty("os.arch", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); public static final String JAVA_VERSION = System.getProperty("java.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); + public static final String JAVAFX_VERSION = System.getProperty("javafx.runtime.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); + public final Version version; public final String authors; diff --git a/src/main/java/org/jabref/logic/util/JavaVersion.java b/src/main/java/org/jabref/logic/util/JavaVersion.java deleted file mode 100644 index 396d6dfbfe5..00000000000 --- a/src/main/java/org/jabref/logic/util/JavaVersion.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.jabref.logic.util; - -import java.util.Scanner; -import java.util.regex.Pattern; - -/** - * Provides simple checks to ensure the correct version for JabRef is available. Currently, we need to make sure that we - * have Java 1.8 but not Java 9. The functions here are not intended for direct use. Instead, they are called inside - * {@link BuildInfo}, which has the required java version string (e.g. 1.8.0_144) available through the build system. - * The version check should always happen through the Globals#BUILD_INFO instance which is available at a - * very early stage in the JabRef startup. - */ -public class JavaVersion { - - // See http://openjdk.java.net/jeps/223 - private static final Pattern DELIMITER = Pattern.compile("[._\\-+]"); - private final String JAVA_VERSION; - - public JavaVersion() { - // Be adventurous and assume that we can always access this property! - JAVA_VERSION = System.getProperty("java.version"); - } - - public JavaVersion(final String version) { - JAVA_VERSION = version; - } - - /** - * Tries to determine if we are running on Java 9. This test should return false, when we cannot extract the correct - * Java version. Note that Java 9 has a different version scheme like "9-internal". - * - * @return true if Java 9 is used - */ - public boolean isJava9() { - if (JAVA_VERSION != null) { - // Since isAtLeast is very optimistic, we first need to check if we have a "number" in the version string - // at all. Otherwise we would get false-positives. - final Scanner scanner = new Scanner(JAVA_VERSION); - scanner.useDelimiter(DELIMITER); - if (scanner.hasNextInt()) { - return isAtLeast("1.9"); - } - } - return false; - } - - /** - * A very optimistic test for ensuring we at least have a minimal required Java version. It will not fail when we - * cannot determine the result. In essence, this method splits a version string using {@link - * JavaVersion#DELIMITER} and compares two version number by number. - * - * @param version Should be in the form X.X.X_XXX where X are integers. - * @return true if the numbers in version available for comparison are all greater-equals the currently running Java - * version. - */ - public boolean isAtLeast(final String version) { - if (JAVA_VERSION == null || version == null) { - return true; - } - final Scanner scannerRunningVersion = new Scanner(JAVA_VERSION); - final Scanner scannerRequiredVersion = new Scanner(version); - scannerRunningVersion.useDelimiter(DELIMITER); - scannerRequiredVersion.useDelimiter(DELIMITER); - while (scannerRunningVersion.hasNextInt() && scannerRequiredVersion.hasNextInt()) { - final int running = scannerRunningVersion.nextInt(); - final int required = scannerRequiredVersion.nextInt(); - if (running == required) { - continue; - } - return running >= required; - } - return true; - } - - public String getJavaVersion() { - return JAVA_VERSION; - } - - public String getJavaInstallationDirectory() { - return System.getProperty("java.home"); - } -} diff --git a/src/test/java/org/jabref/logic/util/JavaVersionTest.java b/src/test/java/org/jabref/logic/util/JavaVersionTest.java deleted file mode 100644 index 662549e4364..00000000000 --- a/src/test/java/org/jabref/logic/util/JavaVersionTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.jabref.logic.util; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests for ensuring we can compare most appearing version strings - */ -public class JavaVersionTest { - - private static List java = new ArrayList<>(); - private static List java9 = new ArrayList<>(); - - static { - java.add("1.6.0_10"); // Oracle - java.add("1.6.0_45"); // Oracle - java.add("1.7.0_13"); // Oracle - java.add("1.8.0_76-release"); // openjdk - java.add("1.8.0_92"); // Oracle - java.add("1.8.0_111"); // Oracle - java.add("1.8.0_112-release"); // openjdk - java.add("1.8.0_152-release"); // openjdk - java.add("1.8.0_144"); // Oracle - - // Examples http://openjdk.java.net/jeps/223 - // Note that it might be possible that java 9 versions are either 9.1.4+8 or new style 1.9.0_31-b08 - java9.add("9-internal"); // openjdk - java9.add("1.9.0_20-b62"); - java9.add("1.9.0_20-b62"); - java9.add("9.2.4+45"); - } - - @Test - public void isJava9() throws Exception { - // Check that all valid java versions below 9 are recognized as not java 9 - for (String versionString : java) { - final JavaVersion java8 = new JavaVersion(versionString); - assertFalse(java8.isJava9()); - } - // Check if all valid version 9 strings are recognized as being version 9 - for (String version9String : java9) { - final JavaVersion java9 = new JavaVersion(version9String); - assertTrue(java9.isJava9()); - } - - // For impossible comparisons we assume it's not java 9 - assertFalse(new JavaVersion(null).isJava9()); - assertFalse(new JavaVersion("U.N.K.N.O.W.N").isJava9()); - } - - @Test - public void isAtLeast() throws Exception { - final JavaVersion java8 = new JavaVersion("1.8"); - for (String version8 : java) { - assertTrue(java8.isAtLeast(version8)); - final JavaVersion java8Example = new JavaVersion(version8); - assertTrue(java8Example.isAtLeast("1.5")); - - // Check if we optimistically return true if we cannot determine the result - assertTrue(java8Example.isAtLeast(null)); - assertTrue(new JavaVersion(null).isAtLeast(version8)); - assertTrue(new JavaVersion("U.N.K.N.O.W.N").isAtLeast(version8)); - assertTrue(java8Example.isAtLeast("useless")); - - // Check against all java 9 entries in both directions - for (String version9 : java9) { - assertFalse(java8Example.isAtLeast(version9)); - final JavaVersion java9 = new JavaVersion(version9); - assertTrue(java9.isAtLeast(version8)); - } - } - } -}