1

I've been working with Java for a bit now and the JDK/JRE version has given me quite a bit of trouble lately. I am developing using the Intellij IDEA IDE and it of course uses the latest version of the JDK, 14. However when I attempt to execute software compiled with JDK 14 outside the IDE, I get an error that the JRE isn't new enough to run this software. So I updated Java on my computer and another machine and attempt to run again without any success. After some digging, I tweaked my machine to use the JRE included in the JDK 14 which is compatible.

However it is kind of odd that I had to do that, one would think that the latest version of java should of been enough to run applications made with the latest version of the JDK (14). Right now Java is version 8 build 251 and says there is no newer update available. If JDK 14 is out for a while now, why would they not update the version of Java they ship?

The problem is partially solved, as only the machine I am using for development is capable of executing the created applications. Other people I've sent them to have been unable to run them, despite having the latest version of java. Also it is a pain to get the latest JDK, especially when having limited experience on how to get rid of old versions, change path point to the latest version, get the right package (open/oracle JDK) and do that for windows and several distrubutions of linux. What is going on? Did I get Java from the wrong place and everyone else as well? Why are oracle doing this and why are there no java updates since clearly there exists a newer version?

  • jdk versions do not match java runtime versions. runtime is much way back in number – DrkDeveloper Jul 04 '20 at 12:40
  • @DrkDeveloper that seems to be the case, i do not know why that is. So for people to use my apps, they need to get the JDK? I was thinking that I should ship my applications as they are, and wait 5 years for java version to catch up. – DuckHunterZx Jul 04 '20 at 12:51
  • Read [*Java Client Roadmap Update*](https://www.oracle.com/technetwork/java/javase/javaclientroadmapupdatev2020may-6548840.pdf) and [*Java Is Still Free*](https://medium.com/@javachampions/java-is-still-free-2-0-0-6b9aa8d6d244). – Basil Bourque Jul 04 '20 at 16:54

3 Answers3

2

You're confusing how IntelliJ or JDK are used on the OS. IntelliJ, now, often comes with its JDK binaries (but even this can be configured, IntelliJ can be configured to use any JDK/JRE build you'll provide to it); however, if you run your Java application out of IntelliJ, most likely you're using Java installed locally on your OS, which might be referenced via your JAVA_HOME environment variable.

I'd suggest to:

  1. Check java -version in your shell (and hence you'll see what JVM instance your OS spins up when you run a Java application);
  2. Check where java (on Windows, or which - on Linux) in your shell, to see all the Java binaries available on your OS.
Giorgi Tsiklauri
  • 6,699
  • 7
  • 29
  • 54
  • Inside of Intellij idea, OpenJDK 14 was initially used. Outside of it, Java 8 251 for both javac and java. I now configured both IDEA and the OS to use Java SE 14, so there is no version mismatch anymore. The problem is that most other people simply have Java on their machines and are unable to run any aplpication developed in JDK 14 despite having the latest version. However I do not think I confused the JDK used in either case. Thank you. – DuckHunterZx Jul 04 '20 at 12:59
  • If the Java machine you have, is older, than the bytecode you've compiled (with, for instance, JDK14), then it won't run, and that's logical. I usually think, that it's best to have a once JDK, and set your IDE using that same JDK. – Giorgi Tsiklauri Jul 04 '20 at 13:03
  • That makes sense, its just that people I know cannot run the applications developed with the newest JDK (since they have plain old java jre). I was thinking of wrapping them with my own JRE image into an executable. – DuckHunterZx Jul 04 '20 at 13:06
  • @DuckHunterZx could you share with us what you did? how you solved your problem? which answer helped you? it's always good idea to follow up the problem you were looking for and people tried to help you. – Giorgi Tsiklauri Jul 06 '20 at 06:29
  • Well basically I realized that downloading Java doesn't do the trick anymore since JRE and JDK don't exist seperately anymore. I realize that in order to ship my application, ensuring the end user has the required version of java I need to package it using a custom jre image using jlink and jpackage. But binaries are not cross platform. So basically I am forced to choose between a cross platform JAR which requires a version of the JRE the end user likely doens't have or a binary, which is not cross platform. – DuckHunterZx Jul 08 '20 at 09:27
1

Starting with Java-11, separate JRE does not exist anymore. In other words, if you are using Java-11 or above, you should care about JDK only.

You should uninstall JRE-8 from your machine and make sure your JDK-14 bin folder in the PATH variable. Some application even requires JAVA_HOME to work and therefore you should make sure that your system has an environment variable called JAVA_HOME and its value set to the root folder of JDK-14 (i.e. one level above your JDK bin).

Q: What should my clients do to run my application compiled on JDK-14?

Ans: Your clients must install JDK-14. Also, check this thread for some alternatives.

Arvind Kumar Avinash
  • 50,121
  • 5
  • 26
  • 72
  • Thanks I did not know that. I no longer have trouble with the version on my machine. Now say you're a user (not a developer), who wishes to run a Java application developed with JDK 14. What would you have to download in order to run it? – DuckHunterZx Jul 04 '20 at 13:14
  • @DuckHunterZx - I've updated my answer and added it as a Q/A at the end. I hope, it helps. – Arvind Kumar Avinash Jul 04 '20 at 13:24
  • 1
    @DuckHunterZx Note this information is specific to Java distributions provided by Oracle. Other Java distributors still offer "JRE-only" downloads. However, if you're deploying a desktop application you might want to consider bundling the JRE with your application (e.g. using `jlink` and/or `jpackage`, or some third-party mechanism). – Slaw Jul 04 '20 at 13:48
-1

Try to uninstall Java SE Development Kit and Java JRE(if you have both in your machine) and reinstall both again, JDK and JRE both, I am sharing my google drive link where you can find the latest version of both JDK and JRE and when you are done installing, add there bin folder path in the Environment Variables of your machine.