Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request]: Replace the "Error: could not find or load main class @user_jvm_args.txt" message #445

Open
1 task done
chorbintime opened this issue Dec 10, 2022 · 12 comments
Assignees
Labels
enhancement New feature, request or improvement help wanted Extra attention is needed

Comments

@chorbintime
Copy link

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

  • I agree to follow this project's Code of Conduct
@chorbintime chorbintime added the enhancement New feature, request or improvement label Dec 10, 2022
@Griefed
Copy link
Owner

Griefed commented Dec 10, 2022

As I mentioned in Discord, it is a message generated by Java/Forge, not SPC, so I can not guarantee anything. :)

@Griefed Griefed changed the title [Feature request]: [Feature request]: Replace the "Error: could not find or load main class @user_jvm_args.txt" message Dec 31, 2022
@Griefed
Copy link
Owner

Griefed commented Mar 28, 2023

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

@chorbintime
Copy link
Author

Its okay!

@Griefed Griefed added the help wanted Extra attention is needed label Oct 8, 2023
@DisruptionSystemsINC
Copy link

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

@DisruptionSystemsINC
Copy link

There is probably also easier or less convoluted ways to do this, but this is what i came up with for now

@chorbintime
Copy link
Author

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)

@DisruptionSystemsINC
Copy link

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

@chorbintime
Copy link
Author

Running a server or client with a newer version of Java results in a major performance boost.

@Griefed
Copy link
Owner

Griefed commented Jun 2, 2024

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.

@chorbintime
Copy link
Author

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

@Griefed
Copy link
Owner

Griefed commented Jun 3, 2024

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.

@chorbintime
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, request or improvement help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants