[Feature request]: Replace the "Error: could not find or load main class @user_jvm_args.txt" message
Whats the feature you would like to be added?
Replace the "Error: could not find or load main class @user_jvm_args.txt" message that is generated when the wrong java version is being used with something more readable such as "Wrong java version installed!"
Anything else you would like to add?
No
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
As I mentioned in Discord, it is a message generated by Java/Forge, not SPC, so I can not guarantee anything. :)
Heya Chorb,
just poppin in to let you know that, unfortunately, I haven't had time to investigate this and whether a nice solution would be or is possible. It may be a while before I get to seriously tackle this. Unless someone else comes around and presents a nice solution to this issue.
Cheers, Griefed
Its okay!
Heya Chorb,
just poppin in to let you know that, unfortunately, I haven't had time to investigate this and whether a nice solution would be or is possible. It may be a while before I get to seriously tackle this. Unless someone else comes around and presents a nice solution to this issue.
Cheers, Griefed
Could maybe try to catch the issue before java does within the bash/batch script, i.e add another check like the one for the java-bit-ness
Could look like this (At least for the bash script):
checkJavaVersion() {
# Define the minimum Minecraft version that uses Java 8
min_java8_version="1.6"
# Get the Minecraft version from the environment variable
minecraft_version="$MINECRAFT_VERSION"
# Split the Minecraft version into components
IFS='.' read -ra version_components <<< "$minecraft_version"
# Check if the Minecraft version is less than 1.18
if [[ "${version_components[0]}" -lt 1 || ( "${version_components[0]}" -eq 1 && "${version_components[1]}" -lt 18 ) ]]; then
# For versions below 1.18, check for Java 8
if "$JAVA" -version 2>&1 | grep -q "1."; then
echo "WARNING! Incorrect Java version detected, versions $min_java8_version to 1.17 use Java 8."
crash
else
echo "Java version is correct for Minecraft $minecraft_version."
fi
else
# For versions 1.18 and above, check for Java 17
if ! "$JAVA" -version 2>&1 | grep -q "1.1[89]"; then
echo "WARNING! Incorrect Java version detected, Minecraft $minecraft_version uses Java 17 or higher."
crash
else
echo "Java version is correct for Minecraft $minecraft_version."
fi
fi
}
Just call it right after the java bitness check
There is probably also easier or less convoluted ways to do this, but this is what i came up with for now
I wouldn't be so definite on "use java 8 or else", since you can use up to java 21 on 1.16.5 without issue (requires special args though)
I wouldn't be so definite on "use java 8 or else", since you can use up to java 21 on 1.16.5 without issue (requires special args though)
maybe add another variable to the variables.txt like
SkipJavaVersionCheck=false
Should someone really want to use a newer Java version with a Minecraft version
Though, I don't really see a reason why you would want to run it using a newer version of Java
Running a server or client with a newer version of Java results in a major performance boost.
Java checks are available as of https://github.com/Griefed/ServerPackCreator/releases/tag/6.0.0-alpha.3
Checks are based on the info from MultiMC and the info Chorb posted somewhere, as in MC 1.16 and older can use Java 8 and 11, everything else has a "minimum required" check.
This should aleviate at least a portion of problems on the users side for their Java version.
Thank you so much! I would maybe add an option somewhere to bypass the Java requirement, as some special args can allow super new Java versions to work on older versions. This would only be for advanced users though, so you could add it to variables.txt or something, and add a message when the server gets force-crashed that tells the user? Up to you how you'd want to execute this I suppose, but some sort of bypasss would be nice! Thanks again
A skip is no problem at all, not even much work. I'll add it. Out of curiosity, is there a wiki or faq regarding the arguments you mentioned, or do you have your own documentation?
Might be worthwhile to add a section to the SPC help-docs. THe more the merrier.
As for the force-crash message: That's a tricky one, as I can't reliably catch the crash reason of the server across all scripts. I'll add a message if the skip is active which get#s displayed after the server stops, regardless of why it stopped.
The only guide I know of would be https://github.com/embeddedt/ModernFix/wiki/1.16---required-arguments-for-Java-17
Check out the latest alpha build: https://github.com/Griefed/ServerPackCreator/releases/tag/6.0.0-alpha.11
It not only has Java compatibility checks, which were added in alpha 3, but also automated Java installation based on the Java version recommended by Mojang themselves.
I'd appreciate some tests on this. :)
Available as of 6.0.0