Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output java error on console, too #7222

Merged
merged 6 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ modularity.patchModule("test", "fastparse_2.12-1.0.0.jar")
modularity.patchModule("test2", "fastparse-utils_2.12-1.0.0.jar")
modularity.patchModule("test3", "sourcecode_2.12-0.1.4.jar")

// These are the Java version requirements we will check on each start of JabRef
ext.minRequiredJavaVersion = "1.8.0_171"
ext.allowJava9 = true

sourceSets {
main {
java {
Expand Down Expand Up @@ -271,10 +267,7 @@ processResources {
"azureInstrumentationKey": System.getenv('AzureInstrumentationKey'),
"springerNatureAPIKey": System.getenv('SpringerNatureAPIKey'),
"astrophysicsDataSystemAPIKey": System.getenv('AstrophysicsDataSystemAPIKey'),
"ieeeAPIKey": System.getenv('IEEEAPIKey'),
"minRequiredJavaVersion": minRequiredJavaVersion,
"allowJava9": allowJava9

"ieeeAPIKey": System.getenv('IEEEAPIKey')
)
filteringCharset = 'UTF-8'
}
Expand Down
50 changes: 0 additions & 50 deletions src/main/java/org/jabref/gui/JabRefMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.stage.Stage;

import org.jabref.cli.ArgumentProcessor;
Expand All @@ -19,8 +18,6 @@
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.RemotePreferences;
import org.jabref.logic.remote.client.RemoteClient;
import org.jabref.logic.util.BuildInfo;
import org.jabref.logic.util.JavaVersion;
import org.jabref.logic.util.OS;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.database.BibDatabaseMode;
Expand Down Expand Up @@ -48,8 +45,6 @@ public static void main(String[] args) {
@Override
public void start(Stage mainStage) {
try {
// Fail on unsupported Java versions
ensureCorrectJavaVersion();
FallbackExceptionHandler.installExceptionHandler();

// Init preferences
Expand Down Expand Up @@ -93,51 +88,6 @@ public void stop() {
Globals.shutdownThreadPools();
}

/**
* Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported.
* This test uses the requirements for the Java version as specified in <code>gradle.build</code>. It is possible to
* define a minimum version including the built number and to indicate whether Java 9 can be used (which it currently
* can't). It tries to compare this version number to the version of the currently running JVM. The check is
* optimistic and will rather return true even if we could not exactly determine the version.
* <p>
* Note: Users with a very old version like 1.6 will not profit from this since class versions are incompatible and
* JabRef won't even start. Currently, JabRef won't start with Java 9 either, but the warning that it cannot be used
* with this version is helpful anyway to prevent users to update from an old 1.8 directly to version 9. Additionally,
* we soon might have a JabRef that does start with Java 9 but is not perfectly compatible. Therefore, we should leave
* the Java 9 check alive.
*/
private static void ensureCorrectJavaVersion() {
// Check if we are running an acceptable version of Java
final BuildInfo buildInfo = Globals.BUILD_INFO;
JavaVersion checker = new JavaVersion();
final boolean java9Fail = !buildInfo.allowJava9 && checker.isJava9();
final boolean versionFail = !checker.isAtLeast(buildInfo.minRequiredJavaVersion);

if (java9Fail || versionFail) {
StringBuilder versionError = new StringBuilder(
Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.",
checker.getJavaVersion(),
buildInfo.minRequiredJavaVersion));

versionError.append("\n");
versionError.append(Localization.lang("Your Java Runtime Environment is located at %0.", checker.getJavaInstallationDirectory()));

if (!buildInfo.allowJava9) {
versionError.append("\n");
versionError.append(Localization.lang("Note that currently, JabRef does not run with Java 9."));
}

FXDialog alert = new FXDialog(Alert.AlertType.ERROR, Localization.lang("Error"), true);
alert.setHeaderText(null);
alert.setContentText(versionError.toString());

// We exit on Java 9 error since this will definitely not work
if (java9Fail) {
System.exit(0);
}
}
}

private static boolean handleMultipleAppInstances(String[] args) {
RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences();
if (remotePreferences.useRemoteServer()) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/logic/l10n/Localization.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private Localization() {
public static String lang(String key, String... params) {
if (localizedMessages == null) {
// I'm logging this because it should never happen
LOGGER.error("Messages are not initialized before accessing key: " + key);
LOGGER.error("Messages are not initialized before accessing key: {}", key);
setLanguage(Language.ENGLISH);
}
return lookup(localizedMessages, key, params);
Expand All @@ -67,7 +67,7 @@ public static void setLanguage(Language language) {
Optional<Locale> knownLanguage = Language.convertToSupportedLocale(language);
final Locale defaultLocale = Locale.getDefault();
if (knownLanguage.isEmpty()) {
LOGGER.warn("Language " + language + " is not supported by JabRef (Default:" + defaultLocale + ")");
LOGGER.warn("Language {} is not supported by JabRef (Default: {})", language, defaultLocale);
setLanguage(Language.ENGLISH);
return;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private static String lookup(LocalizationBundle bundle, String key, String... pa

String translation = bundle.containsKey(key) ? bundle.getString(key) : "";
if (translation.isEmpty()) {
LOGGER.warn("Warning: could not get translation for \"" + key + "\" for locale " + Locale.getDefault());
LOGGER.warn("Warning: could not get translation for \"{}\" for locale {}", key, Locale.getDefault());
translation = key;
}
return new LocalizationKeyParams(translation, params).replacePlaceholders();
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ azureInstrumentationKey=${azureInstrumentationKey}
springerNatureAPIKey=${springerNatureAPIKey}
astrophysicsDataSystemAPIKey=${astrophysicsDataSystemAPIKey}
ieeeAPIKey=${ieeeAPIKey}
minRequiredJavaVersion = ${minRequiredJavaVersion}
allowJava9 = ${allowJava9}
3 changes: 0 additions & 3 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1779,16 +1779,13 @@ Checking\ integrity...=Checking integrity...

Remove\ hyphenated\ line\ breaks=Remove hyphenated line breaks
Removes\ all\ hyphenated\ line\ breaks\ in\ the\ field\ content.=Removes all hyphenated line breaks in the field content.
Note\ that\ currently,\ JabRef\ does\ not\ run\ with\ Java\ 9.=Note that currently, JabRef does not run with Java 9.
Your\ current\ Java\ version\ (%0)\ is\ not\ supported.\ Please\ install\ version\ %1\ or\ higher.=Your current Java version (%0) is not supported. Please install version %1 or higher.

Could\ not\ retrieve\ entry\ data\ from\ '%0'.=Could not retrieve entry data from '%0'.
Entry\ from\ %0\ could\ not\ be\ parsed.=Entry from %0 could not be parsed.
Invalid\ identifier\:\ '%0'.=Invalid identifier: '%0'.
This\ paper\ has\ been\ withdrawn.=This paper has been withdrawn.
Finished\ writing\ XMP\ metadata.=Finished writing XMP metadata.
empty\ citation\ key=empty citation key
Your\ Java\ Runtime\ Environment\ is\ located\ at\ %0.=Your Java Runtime Environment is located at %0.
Aux\ file=Aux file
Group\ containing\ entries\ cited\ in\ a\ given\ TeX\ file=Group containing entries cited in a given TeX file

Expand Down