Merge pull request #46 from muscaln/java
This commit is contained in:
commit
3b524e99cc
@ -120,8 +120,8 @@ void JavaInstallList::updateListData(QList<BaseVersionPtr> versions)
|
|||||||
|
|
||||||
bool sortJavas(BaseVersionPtr left, BaseVersionPtr right)
|
bool sortJavas(BaseVersionPtr left, BaseVersionPtr right)
|
||||||
{
|
{
|
||||||
auto rleft = std::dynamic_pointer_cast<JavaInstall>(left);
|
auto rleft = std::dynamic_pointer_cast<JavaInstall>(right);
|
||||||
auto rright = std::dynamic_pointer_cast<JavaInstall>(right);
|
auto rright = std::dynamic_pointer_cast<JavaInstall>(left);
|
||||||
return (*rleft) > (*rright);
|
return (*rleft) > (*rright);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +149,21 @@ JavaInstallPtr JavaUtils::GetDefaultJava()
|
|||||||
return javaVersion;
|
return javaVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList addJavasFromEnv(QList<QString> javas)
|
||||||
|
{
|
||||||
|
QByteArray env = qgetenv("POLYMC_JAVA_PATHS");
|
||||||
|
#if defined(Q_OS_WIN32)
|
||||||
|
QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(";"));
|
||||||
|
#else
|
||||||
|
QList<QString> javaPaths = QString::fromLocal8Bit(env).split(QLatin1String(":"));
|
||||||
|
#endif
|
||||||
|
for(QString i : javaPaths)
|
||||||
|
{
|
||||||
|
javas.append(i);
|
||||||
|
};
|
||||||
|
return javas;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(Q_OS_WIN32)
|
#if defined(Q_OS_WIN32)
|
||||||
QList<JavaInstallPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString keyName, QString keyJavaDir, QString subkeySuffix)
|
QList<JavaInstallPtr> JavaUtils::FindJavaFromRegistryKey(DWORD keyType, QString keyName, QString keyJavaDir, QString subkeySuffix)
|
||||||
{
|
{
|
||||||
@ -363,7 +378,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Home/bin/java");
|
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Home/bin/java");
|
||||||
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java");
|
||||||
}
|
}
|
||||||
return javas;
|
return addJavasFromEnv(javas);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(Q_OS_LINUX)
|
#elif defined(Q_OS_LINUX)
|
||||||
@ -409,7 +424,7 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
scanJavaDir("/opt/jdks");
|
scanJavaDir("/opt/jdks");
|
||||||
// flatpak
|
// flatpak
|
||||||
scanJavaDir("/app/jdk");
|
scanJavaDir("/app/jdk");
|
||||||
return javas;
|
return addJavasFromEnv(javas);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
QList<QString> JavaUtils::FindJavaPaths()
|
QList<QString> JavaUtils::FindJavaPaths()
|
||||||
@ -419,6 +434,6 @@ QList<QString> JavaUtils::FindJavaPaths()
|
|||||||
QList<QString> javas;
|
QList<QString> javas;
|
||||||
javas.append(this->GetDefaultJava()->path);
|
javas.append(this->GetDefaultJava()->path);
|
||||||
|
|
||||||
return javas;
|
return addJavasFromEnv(javas);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user