From bb4861cf0d5b133da5b18a77700a3b827d2c7d13 Mon Sep 17 00:00:00 2001 From: Tayou Date: Thu, 18 Aug 2022 18:19:28 +0200 Subject: [PATCH 1/2] check for java installs in PATH on windows this should find java installs from scoop as well as any other installer, that registers java in the PATH environment variable. Signed-off-by: Tayou --- launcher/java/JavaUtils.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 2b19fca0..078b22b9 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -177,6 +177,12 @@ QStringList addJavasFromEnv(QList javas) QByteArray env = qgetenv("POLYMC_JAVA_PATHS"); #if defined(Q_OS_WIN32) QList javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";")); + + QByteArray envPath = qgetenv("PATH"); + QList javaPathsfromPath = QString::fromLocal8Bit(envPath).replace("\\", "/").split(QLatin1String(";")); + for (QString string : javaPathsfromPath) { + javaPaths.append(string + "/javaw.exe"); + } #else QList javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":")); #endif From 26f31e9288f65a9e4eb507382cc00ad940e46b09 Mon Sep 17 00:00:00 2001 From: Tayou Date: Thu, 18 Aug 2022 23:16:50 +0200 Subject: [PATCH 2/2] use qEnvironmentVariable instead of qgetenv in JavaUtils Signed-off-by: Tayou --- launcher/java/JavaUtils.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 078b22b9..2f91605b 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -174,17 +174,17 @@ JavaInstallPtr JavaUtils::GetDefaultJava() QStringList addJavasFromEnv(QList javas) { - QByteArray env = qgetenv("POLYMC_JAVA_PATHS"); + auto env = qEnvironmentVariable("POLYMC_JAVA_PATHS"); #if defined(Q_OS_WIN32) - QList javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";")); + QList javaPaths = env.replace("\\", "/").split(QLatin1String(";")); - QByteArray envPath = qgetenv("PATH"); - QList javaPathsfromPath = QString::fromLocal8Bit(envPath).replace("\\", "/").split(QLatin1String(";")); + auto envPath = qEnvironmentVariable("PATH"); + QList javaPathsfromPath = envPath.replace("\\", "/").split(QLatin1String(";")); for (QString string : javaPathsfromPath) { javaPaths.append(string + "/javaw.exe"); } #else - QList javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":")); + QList javaPaths = env.split(QLatin1String(":")); #endif for(QString i : javaPaths) {