-1

I've used VsCode to create a Jar file from my Java Project and works perfectly in my pc.

I tried to use a laptop that had no Java whatsoever to run such Jar; so I just downloaded and installed the latest version of JRE(https://www.java.com/es/download/ie_manual.jsp) since it's the only thing required to run a .jar

But when I try to run the Jar in this separete laptop I get an error message that makes no sense, since I am creating a Jar with an old version of the JDK and executing it with the latest JRE it should work.

My version of JDK is this one: 11.0.12 (I get the same output with "java -version" and "javac -version")

My version of Jre in the other pc is: "1.8.0_321" which is supossed to be the latest version.

And the error i get is the following: Error due versions incompatibility

Has any one encountered this error? Both OS are Windows 10 and when googling for the specific error I just get solutions that say Java has backwards compatibility, to implement a .bat, download a JDK and work from there. But I don't understand why the latest JRE won't run an older version of JDK (which embeded has the JRE and compiler).

  • 3
    1.8 is _NOT_ the latest version. It might be the latest updated version for Java 8, but the latest Java is version 17. That Oracle suggests Java 8 might be related to the latest license changes. I would suggest to use openJDK instead. – Tom Apr 03 '22 at 17:43
  • 2
    Java 8 is from 2014. Java 11 is from 2018. Not sure why you think 2014 > 2018, but it isn't. There were Java 9 and 10 releases as well. So it isn't at all clear how you could be confused. – Elliott Frisch Apr 03 '22 at 17:46
  • So, what version of JRE would run a JDK 11 Jar since there is no separate modules for Run Time? Or is it just possible to run the Jar with a JDK>11? Thanks for the observation! – FariqueFece Apr 03 '22 at 17:49
  • 1
    @FariqueFece You *might* want to [pay attention](https://stackoverflow.com/q/55868821/2970947) to those versions I mentioned (9 and 10); they were important. And significant things happened. – Elliott Frisch Apr 03 '22 at 17:57
  • Try the latest java 11 https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html. – Jawad El Fou Apr 03 '22 at 18:12
  • Post text here rather than images wherever practical. – Basil Bourque Apr 03 '22 at 23:36
  • Java 18 is the latest version, as of last week. See [version history](https://en.wikipedia.org/wiki/Java_version_history). – Basil Bourque Apr 03 '22 at 23:39

1 Answers1

0

Blockquote My version of Jre in the other pc is: "1.8.0_321" which is supossed to be the latest version.

The 1.8 version (JDK 8) is not the latest. It's an older release from 2014. JDK 11 is a newer release from 2018. The latest release is JDK 18 from 03.2022.

Here you can download the JDK 18 from the OpenJDK: https://jdk.java.net/18/

And here from Oracle: https://www.oracle.com/java/technologies/downloads/

Also note that the separation between "JRE" (Java Runtime Environemt) and "JDK" (Java Development Kit) does not exist since JDK 9. Now there is only JDK.

Jakubeeee
  • 666
  • 6
  • 13
  • You're right I confused the terms since when I tried to search for "latest jre" the 1.8 appeared. But there is also another way, in my case I just wantede JRE and you can donwload that from: https://adoptium.net/es/temurin/releases/ , there you select the version you want and will give you the corresponding JRE. If you try "java -version" it will give you a jdk, but if you try "javac -version" it won't recognize such system variable. Hope but approaches help someone – FariqueFece Apr 03 '22 at 19:03
  • 1
    _From Oracle_ there is only JDK, but as noted in the other Q linked by Elliott Frisch, other OpenJDK builders continue to provide a separate JRE, such as Adoptium (formerly AdoptOpenJDK) Azul-Zulu BellSoft-Liberica. (And Amazon-Corretto for Amazon Linux, but that doesn't help this OP.) – dave_thompson_085 Apr 03 '22 at 19:05