Old Minecraft launcher not working when launching a modpack from twitch - java

I am trying to run a minecraft modpack from Twitch. The modpack runs in minecraft version 12.2, so it uses the old minecraft launcher. When I try to launch it, the following is displayed in the game output:
'''
Exception in thread "main" 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)
'''
I was wondering what the error is and how I could go about fixing it.

please try it with another Java Version.
I think the Launcher is to Old for it...

Related

OpenJDK11 java.lang.ClassCastException

java.lang.ClassCastException: class sun.font.CompositeFont cannot be cast to class sun.font.PhysicalFont (sun.font.CompositeFont and sun.font.PhysicalFont are in module java.desktop of loader 'bootstrap')
java.desktop/sun.font.SunFontManager.getDefaultPhysicalFont(SunFontManager.java:1086)
java.desktop/sun.font.SunFontManager.initialiseDeferredFont(SunFontManager.java:965)
java.desktop/sun.font.SunFontManager.initialiseDeferredFonts(SunFontManager.java:831)
java.desktop/sun.font.SunFontManager.loadFonts(SunFontManager.java:3182)
java.desktop/sun.awt.X11FontManager.loadFonts(X11FontManager.java:438)
java.desktop/sun.font.SunFontManager.getAllInstalledFonts(SunFontManager.java:3543)
java.desktop/sun.java2d.SunGraphicsEnvironment.getAllFonts(SunGraphicsEnvironment.java:209)
java.desktop/sun.java2d.HeadlessGraphicsEnvironment.getAllFonts(HeadlessGraphicsEnvironment.java:72)
I have openjdk11 in my Centos server. I have seen this issue fixed by installing fontconfig package in os. Is there a way that i can fix this issue without installing any package?
I tried to copy some the fontconfig.properties files in my $JAVA_HOME/lib/ folder

java module access issue: "Class in a module cannot access class in unnamed module because module x does not read unnamed module y"

My source code compiles on java 7 and runs on java 11.
I am trying to integrate imperva RASP as a java agent in tomcat. However, when I start the tomcat server, it is throwing following exception:
Caused by: java.lang.IllegalAccessError: class sun.security.ec.ECDSASignature (in module jdk.crypto.ec) cannot access class com.imperva.rasp.AgentBridge (in unnamed module #0x66c61024) because module jdk.crypto.ec does not read unnamed module #0x66c61024
at jdk.crypto.ec/sun.security.ec.ECDSASignature.<init>(ECDSASignature.java:118)
at jdk.crypto.ec/sun.security.ec.ECDSASignature.<init>(ECDSASignature.java:106)
at jdk.crypto.ec/sun.security.ec.ECDSASignature$SHA1.<init>(ECDSASignature.java:214)
at jdk.crypto.ec/sun.security.ec.SunEC$ProviderService.newInstance(SunEC.java:102)
at java.base/java.security.Signature.isSpi(Signature.java:331)
The way I am passing java agent is:
JAVA_OPTS="-javaagent:$IMPERVA_JAR $JAVA_OPTS"
I went through multiple posts such as this one about --add-opens argument. Based on that, I am passing JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED"
I can see following statement in the logs:
Picked up JDK_JAVA_OPTIONS: --add-opens=jdk.crypto.ec/sun.security.ec=ALL-UNNAMED
Am I missing something here or is there any syntax error in the arguments that I am passing?
There is no any other configuration is done.
Any help is appreciated. Thank you.
Managed to solve it by using --add-reads instead of --add-opens.
JDK_JAVA_OPTIONS="$JDK_JAVA_OPTIONS --add-reads jdk.crypto.ec=ALL-UNNAMED"

Error: unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader

I am new to the OSGi concept, and any help is appreciated on the below error.
When running the standalone application there are no issues but when the same application is put inside the OSGI bundle we are getting the below error.
Cause exception java.lang.RuntimeException: Could not instantiate
parser org.apache.xerces.parsers.SAXParser:
java.lang.ClassCastException: class
org.apache.xerces.parsers.SAXParser cannot be cast to class
org.xml.sax.Parser (org.apache.xerces.parsers.SAXParser is in unnamed
module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader
#14b4fcf0; org.xml.sax.Parser is in unnamed module of loader
org.eclipse.osgi.internal.loader.EquinoxClassLoader #555c2470)
Please note, the code snippet works with JRE8 + Eclipse 4.4 but failed with the above error with JRE 11 + Eclipse 4.19.
In my application, I am invoking the third-party API, which internally tries to do the above casting, and throws an error.
I understood that this is something related to the OSGi class loader, but need steps to find the cause of this issue. We tried to get more information through the OSGi console as it's a huge application, I can see more than 1000 bundles listed if we execute the SS command on the console.
Thanks in advance.
Regards,
Hrushi
This is due to the changes within Java 9 (Jigsaw). See https://www.logicbig.com/tutorials/core-java-tutorial/modules/unnamed-modules.html.
We had similar issues in our product when upgrading to java 11. This has probably something to do with old libraries which export org.xml.sax somehow. We've upgraded or replaced those libraries to get it fixed

Exception in thread "main" java.lang.NoClassDefFoundError: org/javatuples/Unit

I have imported the javatuples-1.2.jar in Eclipse project. I did this to run the Java Tuples Unit class program. The following is the code:
package mynewpackage;
import org.javatuples.Unit;
class Mynewclass2 {
public static void main(String[] args)
{
Unit<String> u
= new Unit<String>("This is demo text!");
System.out.println(u);
}
}
But, getting the following error on running:
Exception in thread "main" java.lang.NoClassDefFoundError: org/javatuples/Unit
at mynewpackage.Mynewclass2.main(Mynewclass2.java:9)
Caused by: java.lang.ClassNotFoundException: org.javatuples.Unit
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 1 more
Under the references, I can easily see that the tuples jar file is successfully added. However, the following is the project directory, jar in references, error, and the entire program in Eclipse.
How can I fix the issue and run Java Tuples programs correctly?
You have java 11 in place...
When I (try to) reproduce your setup:
My eclipse (Version: 2018-12 (4.10.0), Win_64_jdk_11.0.2) asks me for "module name" and adds src/module-info.java after creation of a "Java Project", ... then download and add lib/javatuples-1.2.jar to build path.
When I try to use/import it in my code (main class) - compilation error, and auto-correct proposes me to add "javatuples" module to module-info:
click-clack:
myproject/src/module-info.java
module myproject {
requires javatuples;
}
After that the program is already runnable, but Eclipse warns:
Name of automatic module 'javatuples' is unstable, it is derived from the module's file name.
To fix this, you can run (from command line):
myproject>jar --file=lib/javatuples-1.2.jar --describe-module
No module descriptor found. Derived automatic module.
javatuples#1.2 automatic
requires java.base mandated
contains org.javatuples
contains org.javatuples.valueintf
So, eclipse warning is already sort of nasty: javatuples is the "correct" module name.
Hope it helps.
Right Click on javatuples-1.2.jar > Build path > Add to Build Path .
NoClassDefFoundError is an error that is thrown when the Java Runtime System tries to load the definition of a class, and that class definition is no longer available.
Comments are Welcome.

How to prevent java.lang.IllegalAccessError with JDK11?

We receive the follow exception in our test system. Any idea how we can prevent this exception for example with a command line switch. And any idea how this exception can occur?
Can the completely access check be disabled in a test system that use intensively reflection and class loading?
java.lang.IllegalAccessError: class java.io.File (in module java.base) cannot access class javax.print.PrintException (in module java.desktop) because module java.base does not read module java.desktop
at java.io.File.exists(File.java)
at jdk.internal.loader.URLClassPath$FileLoader.getResource(URLClassPath.java:1199)
at jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:314)
at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:697)
at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:398)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:67)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)
Try to run it by adding the following command argument.
--add-reads java.base=java.desktop
We solve the problem by updating JMockit version 1.31 with the current version 1.44. It look like the old version is not compatible with the current version.

Categories

Resources