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 <tayou@gmx.net>
This commit is contained in:
Tayou 2022-08-18 18:19:28 +02:00
parent ab766a0598
commit bb4861cf0d

View File

@ -177,6 +177,12 @@ QStringList addJavasFromEnv(QList<QString> javas)
QByteArray env = qgetenv("POLYMC_JAVA_PATHS"); QByteArray env = qgetenv("POLYMC_JAVA_PATHS");
#if defined(Q_OS_WIN32) #if defined(Q_OS_WIN32)
QList<QString> javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";")); QList<QString> javaPaths = QString::fromLocal8Bit(env).replace("\\", "/").split(QLatin1String(";"));
QByteArray envPath = qgetenv("PATH");
QList<QString> javaPathsfromPath = QString::fromLocal8Bit(envPath).replace("\\", "/").split(QLatin1String(";"));
for (QString string : javaPathsfromPath) {
javaPaths.append(string + "/javaw.exe");
}
#else #else
QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":")); QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":"));
#endif #endif