dwhitacre / WindowsGSM.ForgeMC

🧩 WindowsGSM plugin for supporting Minecraft: Forge Server
MIT License
4 stars 2 forks source link

Support multiple java paths via config or `JAVA_HOME` #12

Open CaptainSilver opened 3 years ago

CaptainSilver commented 3 years ago

I'm running a 1.17 and a 1.12 minecraft server which require two different versions of Java 8 and 16 I have java 16 as my env variable I was wondering if I can do something like change line 71

    private Process GetJavaProcess(string args)
    {
        var javaPath = JavaHelper.FindJavaExecutableAbsolutePath(); <<<<
        return new Process
        {

to

var javaPath = "C:\Program Files\Java\jre1.8.0_291\bin\java.exe";

However when I make that change with or without "" it unloads the plugin and shows an error on reload. I hope it's relatively easy thanks.

dwhitacre commented 3 years ago

hm, yea I am unsure if that will be sufficient. There is a couple checks in that file to check if the JRE is installed with the JavaHelper and those may need bypassed as well. I will convert this to a feature request to add support for a specific java path and/or managing via JAVA_HOME.

dwhitacre commented 3 years ago

i need to add something like this https://github.com/WindowsGSM/WindowsGSM/commit/f06d3ea096f91393f11cf36c5c8f67af829483a1

dwhitacre commented 3 years ago

that commit is to the javahelper which I am using... so setting JAVA_HOME should just already work. needs confirmation

dwhitacre commented 3 years ago

yea so all plugins that are using the java helper function will check the JAVA_HOME env var and if it exists, use that as the path. otherwise it goes and tries to set the path to program files / java w/e.

so if you want to have different versions per minecraft server the only option currently is to hack in a hardcoded version into one of the plugins. id like to make that a better experience here at some point.

dwhitacre commented 3 years ago

example of the hack provided by @CaptainSilver https://pastebin.com/5MF1Li6S