Arqade Asked by Lahyte on August 12, 2021
Problem
I want to run two servers, one in 1.17 using Java 16 and the other in 1.12.2 using Java 8.
The argument I want to use in the .bat file is "C:Program FilesJavajre1.8.0_291lib" -jar
but it doesn’t work.
.bat
The full .bat is as such.
@ECHO OFF
java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=true -Daikars.new.flags=true "C:Program FilesJavajre1.8.0_291binjava.exe" -jar forge-1.12.2-14.23.5.2855.jar --nogui
pause
Error message
The error given is:
Error: Could not find or load main class C:Program FilesJavajre1.8.0_291binjava.exe
Caused by: java.lang.ClassNotFoundException: C:Program FilesJavajre1.8.0_291binjava.exe
I don’t know how to resolve the error of the java class not being found.
Additional details
I am running JRE 16 and Java 8 on the same computer. Only the 1.17 servers start with this installation set up.
The 1.12.2 server starts when I uninstall JRE 16.
You need to use the correct binaries.
Suppose Java 15 is in your PATH
variable. Then executing the plain java
command will execute with the Java 15 binary.
C:Program FilesJavajre1.8.0_291binjava.exe
is your java 8 binary.
Thus, to execute forge on Java 8, you don't want to execute the plain java
command, since that is java 15. You will need to qualify the whole path to your Java 8 executable, with the command:
C:Program FilesJavajre1.8.0_291binjava.exe -jar <path to forge jar>
Answered by Polygnome on August 12, 2021
Potential answer
Context
I've installed 2 versions of java, 8 and 16. When I type java -version
in command prompt, java 16 shows up.
The following is my .bat file for forge 1.12.2
@ECHO OFF
java -Xms10G -Xmx10G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:-OmitStackTraceInFastThrow -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=8 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=true -Daikars.new.flags=true -jar forge-1.12.2-14.23.5.2855.jar --nogui
pause
When trying to run a 1.12.2 forger server in this state, the following error message appears.
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:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
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.<init>(Launch.java:34)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
... 6 more
Solution?
I take the java.exe from where I've installed Java 8: C:Program FilesJavajre1.8.0_291bin
.
I put it inside my minecraft folder, in the same file level as the forge jar and bat file.
I use the same .bat as shown above, no modifications.
I run it, and the server turns on.
Answered by Lahyte on August 12, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP