Skip to content

Commit

Permalink
fix: detect and use java path for launching rsprox gui itself too
Browse files Browse the repository at this point in the history
  • Loading branch information
notmeta committed Nov 17, 2024
1 parent c7caa08 commit 72bf60d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion launcher/src/main/kotlin/net/rsprox/launcher/Launcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import java.io.IOException
import java.io.InputStreamReader
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.security.MessageDigest
import java.security.Signature
import java.security.cert.Certificate
Expand Down Expand Up @@ -61,6 +62,26 @@ public class Launcher {
Files.createDirectories(artifactRepo)
}

private fun getJava(): String {
val javaHome = Paths.get(System.getProperty("java.home"))

if (!Files.exists(javaHome)) {
throw FileNotFoundException("JAVA_HOME is not set correctly! directory \"$javaHome\" does not exist.")
}

var javaPath = Paths.get(javaHome.toString(), "bin", "java.exe")

if (!Files.exists(javaPath)) {
javaPath = Paths.get(javaHome.toString(), "bin", "java")
}

if (!Files.exists(javaPath)) {
throw FileNotFoundException("java executable not found in directory \"" + javaPath.parent + "\"")
}

return javaPath.toAbsolutePath().toString()
}

public fun getLaunchArgs(launcherArgs: Array<String>): List<String> {
clean()
download()
Expand All @@ -74,7 +95,7 @@ public class Launcher {
}

return listOf(
"java",
getJava(),
"-cp",
classpath.toString(),
bootstrap.proxy.mainClass,
Expand Down

0 comments on commit 72bf60d

Please sign in to comment.