BloodyMods / ServerStarter

MIT License
99 stars 62 forks source link

Respect JAVA_HOME environment variable #26

Closed bitcynth closed 2 years ago

bitcynth commented 3 years ago

Currently ServerStarter doesn't respect the JAVA_HOME environment variable which causes issues when the default binary for java is Java 14 but the javaArgs includes things only available on Java 8 (Java 8 still being the default for Minecraft).

This can be solved for individual installs by setting forcedJavaPath to the binary but for modpack distribution, this is not ideal as this will change from system to system.

An alternative solution would be to allow environment variables in the forcedJavaPath setting, so that the below example would work:

forcedJavaPath: ${JAVA_HOME}/bin/java

Update

This is also an issue with the start scripts.

For the shell script/Linux version this could very easily be fixed by doing something like the following

# add at the top of the file (or anywhere before the first java call)
JAVA_BIN_DIR="$JAVA_HOME/bin/"

# prepend '${JAVA_BIN_DIR}' to java calls such as below
${JAVA_BIN_DIR}java -d64 -jar serverstarter-1.2.7.jar
BloodWorkXGaming commented 3 years ago

This is now supported in the lastest changes. Any other config option where supporting a environment variable makes sense?

However I don't think changing it in the sh file is a good idea. There is a good chance there is no JAVA_HOME however the java binary is in the PATH (or whatever it is called on Linux ^^) This shouldn't be a problem anyways, as the serverstarter is not limited to java8

bitcynth commented 3 years ago

I can't quite remember what my issue was with Java 14, and the latest changes are good enough for me.

But you could check if JAVA_HOME is set or not in the shell script and fallback to java in the PATH.

I won't close this issue and will let you decide if you want to implement that or not.

If not, feel free to close this issue as I am personally fine with the current solution. :)