Problems creating a start.command file

Ok so since sponge disables the default minecraft GUI I was trying to script a shell that would execute the server in terminal. After fixing the permissions I still encounter an error which I believe is caused by my default java version. Pretty sure I need to be on 8 not 11. This is the output I get every time I run the start.command. Does anyone know how to fix this? Possibly how to switch default java versions on Mac?

A problem occurred running the Server launcher.java.lang.reflect.InvocationTargetException

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:564)

at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.run(ServerLaunchWrapper.java:70)

at net.minecraftforge.fml.relauncher.ServerLaunchWrapper.main(ServerLaunchWrapper.java:34)

Caused by: java.lang.ClassCastException: class jdk.internal.loader.ClassLoaders$AppClassLoader cannot be cast to class java.net.URLClassLoader (jdk.internal.loader.ClassLoaders$AppClassLoader and java.net.URLClassLoader are in module java.base of loader ‘bootstrap’)

at net.minecraft.launchwrapper.Launch.(Launch.java:34)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

… 6 more

logout

Saving session…

…copying shared history…

…saving history…truncating history files…

…completed.

[Process completed]

Yep thats the not java 8 error.

When it comes to what application get the command for any application on mac, windows or linux, its based upon what the command shell can access first. It typically searches your current folder for a application called java, failing that it will use the path system.

So you have two options. The first is to change the Java_Home variable which is the path to the java application. Currently it will be set to the java 11, if you change it to the Java 8 location that will change the java command to 8.

The other option is one I have only used in windows, not Linux nor Mac and that it running the specific java application though the shell. In windows you did this by replacing ‘java’ in the command to “'Path_to_java”’ (in quotes). This has the advantage that you only need to do it once (you only need to do the other way one if you dont need java 11)

Why does this happen? Was it because Terminal doesn’t have permission to run?

It crashes as Java 9+ changed how java programs load other Java programs. This change added a lot in terms of what a developer can do, however broke compatibility with old java programs that assumed the loading would never change (it hadnt previously and you kinda need to know how it will change to account for it).

Permissions wise, on Unix like operating system (such as mac and Linux) for security reasons, files downloaded from external sources are classed as none executable (so it cannot run) so if you try to run it (though terminal or other means) it simply says that it cant.

The terminal itself actually has all the same permissions as the user your logged in as, therefore if you can run something, write some or read something, you can do it in the terminal too. If your a admin you can override the permissions for a single command too by providing “sudo” before the command (however if its a execution permission issue then the “chmod” command should be used on it instead of sudo as sudo overrides all permissions).

If your on Windows, you dont get the luxury of execution permission, but instead “run as admin” which you cannot fine tune. But it means that issues with permissions comes up less.

Hope that helps. Didnt know what you meant by “this” as the error was “assumed” solved with my previous comment

1 Like