Skip to content
Open
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
3 changes: 3 additions & 0 deletions client/src/com/mirth/connect/client/ui/BrandingConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class BrandingConstants {
// The URL that is opened when clicking "Help" button in Administrator
public static String HELP_URL_LOCATION = "https://github.com/OpenIntegrationEngine/engine/discussions";

// The URL that is opened when clicking "System Requirements" button in the error dialog when an unsupported Java version is detected
public static final String SYSTEM_REQUIREMENTS_URL = "https://docs.openintegrationengine.org/engine/getting_started.html#system-requirements";

// The "More info" in Server settings "Provide usage statistics"
public static final String PRIVACY_URL = "https://github.com/openintegrationengine";
public static final String PRIVACY_TOOLTIP = "Privacy Information";
Expand Down
28 changes: 28 additions & 0 deletions client/src/com/mirth/connect/client/ui/ClientPrerequisites.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MPL-2.0
// SPDX-FileCopyrightText: Mitch Gaffigan <mitch@gaffigan.net>

package com.mirth.connect.client.ui;

/** Utility class to check if the client prerequisites are met. */
public class ClientPrerequisites {

private ClientPrerequisites() {
}

/** Checks if the client prerequisites are met. */
public static String getMissing() {
// Can't meaningfully check for Java 17 since the entrypoint is compiled with
// class file version 61, which will fail to load on Java 8.
if (!hasJavaFx()) {
return "JavaFX";
}

return null;
}

private static boolean hasJavaFx() {
// Use JPMS to check for JavaFX - the classes are on the classpath
// even in Java SE, but the module will not be present except in FX
return ModuleLayer.boot().findModule("javafx.graphics").isPresent();
}
}
26 changes: 26 additions & 0 deletions client/src/com/mirth/connect/client/ui/Mirth.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.Desktop;
import java.io.IOException;
import java.util.prefs.Preferences;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
Expand Down Expand Up @@ -253,6 +255,13 @@ public static void initUIManager() {
* String[]
*/
public static void main(String[] args) {
var missingPrerequisite = ClientPrerequisites.getMissing();
if (missingPrerequisite != null) {
showUnsupportedJreDialog(missingPrerequisite);
System.exit(1);
return;
}

CommandLineOptions opts = new CommandLineOptions(args);

if (StringUtils.isNotBlank(opts.getProtocols())) {
Expand All @@ -267,6 +276,23 @@ public static void main(String[] args) {
start(opts.getServer(), opts.getVersion(), opts.getUsername(), opts.getPassword());
}

private static void showUnsupportedJreDialog(String missingPrerequisite) {
try {
var message = String.format(
"%s Client requires %s%nPlease review the system requirements and try again.",
BrandingConstants.PRODUCT_NAME, missingPrerequisite);
var options = new Object[] { "View System Requirements", "Exit" };
var result = JOptionPane.showOptionDialog(
null, message, "Unsupported Java Runtime", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]);

if (result == 0) {
Desktop.getDesktop().browse(java.net.URI.create(BrandingConstants.SYSTEM_REQUIREMENTS_URL));
}
} catch (Throwable t) {
System.err.println(String.format("Missing prerequisite: %s", missingPrerequisite));
}
}

private static void start(final String server, final String version, final String username, final String password) {
// disable the velocity logging
Logger velocityLogger = LogManager.getLogger(RuntimeConstants.DEFAULT_RUNTIME_LOG_NAME);
Expand Down
Loading