diff --git a/back/electron-tools.js b/back/electron-tools.js index f10ae44..dbde96a 100644 --- a/back/electron-tools.js +++ b/back/electron-tools.js @@ -1,4 +1,4 @@ -const { BrowserWindow } = require("electron") +const { BrowserWindow, dialog } = require("electron") function getMainWindow(){ @@ -12,6 +12,12 @@ function getMainWindow(){ } +function errorWindow(title, message){ + dialog.showErrorBox(title, message) +} + + module.exports = { - getMainWindow + getMainWindow, + errorWindow } diff --git a/back/settings.js b/back/settings.js index 6513d9d..fa16927 100644 --- a/back/settings.js +++ b/back/settings.js @@ -2,6 +2,19 @@ const fs = require("fs") const path = require("path") const {appDataDir} = require("./config") const {findJava} = require("./utils"); +const {errorWindow} = require("./electron-tools"); + +const javaPath = findJava() +if(javaPath === null){ + errorWindow( + "Java not found", + "No Java installation was found on your system.\n" + + "Please install at least one Java version and try again.\n\n" + + "If you have already installed Java, please make sure that it is in your PATH environment variable.\n\n" + + "Java can be downloaded from https://java.com/download" + ) + process.exit(1) +} class Settings { constructor(){ @@ -9,7 +22,7 @@ class Settings { credentials: null, ram: 1024, mcPath: path.join(appDataDir, "..", ".minecraft_swc"), - javaPath: findJava(), + javaPath: javaPath, "splash-width": "1280", "splash-height": "720", "launch-args": "" diff --git a/back/utils.js b/back/utils.js index b89f9c3..1de5cd5 100644 --- a/back/utils.js +++ b/back/utils.js @@ -10,10 +10,14 @@ registerIpcListener("get-ram-amount", () => { function findJava() { - if(platform === "win32"){ - return child_process.execSync("where java.exe").toString().split("\r\n")[0] - }else{ - return child_process.execSync("which java").toString().split("\n")[0] + try{ + if(platform === "win32"){ + return child_process.execSync("where java.exe").toString().split("\r\n")[0] + }else{ + return child_process.execSync("which java").toString().split("\n")[0] + } + } catch(e){ + return null } }