From d2860d6e4296ffd5a74e10d92cb5640961d758f6 Mon Sep 17 00:00:00 2001 From: tc-wleite Date: Thu, 7 Nov 2024 00:28:03 -0300 Subject: [PATCH] '#2357: Warn the user about possibly corrupted JRE. --- .../src/main/java/iped/app/ui/AppMain.java | 2 +- .../app/ui/splash/SplashScreenManager.java | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/iped-app/src/main/java/iped/app/ui/AppMain.java b/iped-app/src/main/java/iped/app/ui/AppMain.java index 3ac075181d..436ab3e223 100644 --- a/iped-app/src/main/java/iped/app/ui/AppMain.java +++ b/iped-app/src/main/java/iped/app/ui/AppMain.java @@ -32,7 +32,7 @@ public class AppMain { private static final String BUNDLED_JRE_VERSION = "11.0.13"; - private static final String HOME_JRE_FOLDER = ".iped/jre-" + BUNDLED_JRE_VERSION; + public static final String HOME_JRE_FOLDER = ".iped/jre-" + BUNDLED_JRE_VERSION; File casePath; diff --git a/iped-app/src/main/java/iped/app/ui/splash/SplashScreenManager.java b/iped-app/src/main/java/iped/app/ui/splash/SplashScreenManager.java index b73efa3268..ed53fe3cb2 100644 --- a/iped-app/src/main/java/iped/app/ui/splash/SplashScreenManager.java +++ b/iped-app/src/main/java/iped/app/ui/splash/SplashScreenManager.java @@ -8,7 +8,9 @@ import java.awt.RenderingHints; import java.awt.SplashScreen; import java.awt.geom.Rectangle2D; +import java.io.File; +import iped.app.ui.AppMain; import iped.engine.Version; import iped.engine.config.ConfigurationManager; import iped.engine.config.SplashScreenConfig; @@ -157,6 +159,30 @@ public void run() { } } catch (IllegalStateException e) { // Splash was already closed, just ignore this exception. + } catch (NoClassDefFoundError | UnsatisfiedLinkError e) { + // Maybe JRE is corrupted + e.printStackTrace(); + + // Check if the OS is Windows + String os = System.getProperty("os.name"); + if (os != null && os.toLowerCase().startsWith("windows")) { + + // Check if user home is valid + File userHome = new File(System.getProperty("user.home")); + if (userHome != null && userHome.exists() && userHome.isDirectory()) { + + // Check if the is a JRE in user home + File userJrePath = new File(userHome, AppMain.HOME_JRE_FOLDER); + if (userJrePath.exists()) { + + // Warn the user about possibly corrupted JRE + System.err.println("\n\nERROR: User JRE may be corrupted!"); + System.err.println("Please, try to delete \"" + userJrePath.getAbsolutePath() + + "\" folder and run IPED again."); + System.err.println(""); + } + } + } } catch (Exception e) { e.printStackTrace(); }