diff --git a/launcher/Application.cpp b/launcher/Application.cpp index 679de711e..20da46187 100644 --- a/launcher/Application.cpp +++ b/launcher/Application.cpp @@ -48,7 +48,6 @@ #include "net/PasteUpload.h" #include "pathmatcher/MultiMatcher.h" #include "pathmatcher/SimplePrefixMatcher.h" -#include "settings/INIFile.h" #include "ui/InstanceWindow.h" #include "ui/MainWindow.h" @@ -106,8 +105,6 @@ #include "icons/IconList.h" #include "net/HttpMetaCache.h" -#include "java/JavaUtils.h" - #include "updater/ExternalUpdater.h" #include "tools/JProfiler.h" @@ -1833,3 +1830,7 @@ QUrl Application::normalizeImportUrl(QString const& url) return QUrl::fromUserInput(url); } } +const QString Application::javaPath() +{ + return FS::PathCombine(m_dataPath, "java"); +} diff --git a/launcher/Application.h b/launcher/Application.h index 85bf2dff4..ba65edd82 100644 --- a/launcher/Application.h +++ b/launcher/Application.h @@ -162,6 +162,9 @@ class Application : public QApplication { /// the data path the application is using const QString& dataRoot() { return m_dataPath; } + /// the java installed path the application is using + const QString javaPath(); + bool isPortable() { return m_portable; } const Capabilities capabilities() { return m_capabilities; } diff --git a/launcher/java/JavaUtils.cpp b/launcher/java/JavaUtils.cpp index 67f1fd3a7..ff5ba5efe 100644 --- a/launcher/java/JavaUtils.cpp +++ b/launcher/java/JavaUtils.cpp @@ -337,6 +337,7 @@ QList JavaUtils::FindJavaPaths() } candidates.append(getMinecraftJavaBundle()); + candidates.append(getPrismJavaBundle()); candidates = addJavasFromEnv(candidates); candidates.removeDuplicates(); return candidates; @@ -363,6 +364,7 @@ QList JavaUtils::FindJavaPaths() javas.append(systemLibraryJVMDir.absolutePath() + "/" + java + "/Contents/Commands/java"); } javas.append(getMinecraftJavaBundle()); + javas.append(getPrismJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -393,7 +395,6 @@ QList JavaUtils::FindJavaPaths() scanJavaDir(snap + dirPath); } }; - scanJavaDir(FS::PathCombine(APPLICATION->dataRoot(), "java")); // oracle RPMs scanJavaDirs("/usr/java"); // general locations used by distro packaging @@ -416,6 +417,7 @@ QList JavaUtils::FindJavaPaths() scanJavaDirs(FS::PathCombine(home, ".sdkman/candidates/java")); javas.append(getMinecraftJavaBundle()); + javas.append(getPrismJavaBundle()); javas = addJavasFromEnv(javas); javas.removeDuplicates(); return javas; @@ -429,6 +431,8 @@ QList JavaUtils::FindJavaPaths() javas.append(this->GetDefaultJava()->path); javas.append(getMinecraftJavaBundle()); + javas.append(getPrismJavaBundle()); + javas.removeDuplicates(); return addJavasFromEnv(javas); } #endif @@ -484,3 +488,25 @@ QStringList getMinecraftJavaBundle() } return javas; } + +QStringList getPrismJavaBundle() +{ + QList javas; + QDir dir(APPLICATION->javaPath()); + if (!dir.exists()) + return javas; + + QString executable = "java"; +#if defined(Q_OS_WIN32) + executable += "w.exe"; +#endif + + auto entries = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); + for (auto& entry : entries) { + QString prefix; + prefix = entry.canonicalFilePath(); + javas.append(FS::PathCombine(prefix, "jre", "bin", executable)); + javas.append(FS::PathCombine(prefix, "bin", executable)); + } + return javas; +} diff --git a/launcher/java/JavaUtils.h b/launcher/java/JavaUtils.h index 0beb8c67a..aa5315a19 100644 --- a/launcher/java/JavaUtils.h +++ b/launcher/java/JavaUtils.h @@ -26,6 +26,7 @@ QString stripVariableEntries(QString name, QString target, QString remove); QProcessEnvironment CleanEnviroment(); QStringList getMinecraftJavaBundle(); +QStringList getPrismJavaBundle(); class JavaUtils : public QObject { Q_OBJECT diff --git a/launcher/ui/java/JavaDownloader.cpp b/launcher/ui/java/JavaDownloader.cpp index 3552f0ef5..4495210c3 100644 --- a/launcher/ui/java/JavaDownloader.cpp +++ b/launcher/ui/java/JavaDownloader.cpp @@ -85,7 +85,7 @@ void Downloader::accept() return; } Task::Ptr task; - auto final_path = FS::PathCombine(APPLICATION->dataRoot(), "java", meta->vendor, meta->m_name); + auto final_path = FS::PathCombine(APPLICATION->javaPath(), meta->m_name); switch (meta->downloadType) { case Java::DownloadType::Manifest: task = makeShared(meta->url, final_path, meta->checksumType, meta->checksumHash);