Fehlermeldung Java Programm in CMD beheben?
Habe angefangen mir das programmieren beizubringen. Habe also das klassische "HalloWelt" Programm erstellt und wollte das auch gleich in die CMD einfügen... Habe also
mit "javac HalloWelt" die Datei in Maschinensprache kompilliert und wollte das dann mit "java HalloWelt" ausführen. Da kam allerdings diese Fehlermeldung:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HalloWelt has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 52.0
muss ich eine neue JRE Version installieren? Und wenn ja, weiß könnte mir jemand erklären, wie das funktioniert? Bin ein echt großer Noob was PC´s angeht :D
2 Antworten
richtig, neueste runtime installieren und alles ist fein
Habe das gefunden :
My problem was that I had Java JDK 12 installed on my computerAt the same time, I had Java 8 (JRE) Installed on my computer.
So my computer is getting confused.
With my command prompt environment setup to run Java and Javac commands:
I typed the follow commands:
java -version
// this gave me Java 8
After that, I typed:
javac -version
// this gave me Java 12
In other words, my program is getting compiled with Java 12 and I am trying to run with Java 8.
To solve the problem, I uninstalled Java 8 JRE from my computer.
Went back to command prompt to check if "java -version" and "javac -version" is returning the same version number, and yes, it is returning Java 12.
Tried recompiling my program again, and running it. It Worked!!
Vielleicht bei Dir das gleiche Problem.