3

On a desktop with a dual boot I currently have Java JDK 8 in the Linux (Mint) system

chris@M17A ~ $ sudo apt install default-jdk
...
default-jdk is already the newest version (2:1.8-56ubuntu2).
...
chris@M17A ~ $ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

But I'm sure that in fact 1.8.0_171 is not the latest version, even of Java 8! If I want to change to 1.11.xxx, which seems to be the latest LTS release (for Oracle non-OpenJDK at least), what should I do? Do I have to manually download something, or use a PPA? How can I be sure my Linux OS is using the version-11 JRE and the version-11 JDK?

I've also never quite understood either about the versioning of the JRE side of things and how this corresponds to the JDK being used. On my Windows machine (W10) I am using a Java 9 JDK but a Java 8 JRE (I think). Is this a bad thing to do?

This question says there is no such thing in Windows as a Java 11 JRE, although there is a Java 11 JDK. Is that a problem in W10? Would it be a bad idea to use an JDK 11 with a JRE 8?

I also simply don't understand why it is not possible read somewhere about the "latest JRE" or "latest stable JRE". These do not appear to be coupled one-to-one with the latest JDK as far as I can make out but I'm having difficulty obtaining clarity about all this.

I also have some difficulty understanding whether I should opt for OpenJDK or the other JDK (they're both Oracle so I don't know how to refer to the non-OpenJDK one... "commercial JDK"?). But unlike the above difficulties there are lots of explanations out there. I am mainly looking for "latest stable release" hopefully with LTS. Seems like "Commercial JDK" version 11 might be the way to go...

asked Aug 24, 2019 at 13:42
9
  • 1
    A JDK is a superset of a JRE and their versions match. However, Oracle recently stopped providing JRE-only distributions (afaik). And code compiled with newer versions of Java cannot be executed by older versions of Java. Commented Aug 24, 2019 at 14:37
  • OK thanks. So you're saying that ANY byte code compiled with Java 9 SDK must then be executed by a JRE which is >= 9? I find this a little difficult to believe. New features introduced into the language (e.g. lamba stuff) could quite conceivably compile to byte code which was legal in an earlier version of the JVM couldn't it? I mean otherwise people would be forced to update all their OSs running JRE 8 to 9/10/11 all the time wouldn't they? Or else developers would be reluctant to publish apps written with 11...! I find my devices almost never complain about non-executable byte code. Commented Aug 24, 2019 at 14:55
  • 1
    It's not (directly) about added/removed features. A class file has a version flag and the JVM refuses to execute code compiled by newer versions of Java, throwing an UnsupportedClassVersionError. Java only strives for backwards compatibility (meaning Java N compiled code can run on Java >= N). That said, there's cross-compilation. Commented Aug 24, 2019 at 15:06
  • FYI, with the demise of both Java Applets and Java Web Start, there is no more JRE that I know of for the latest versions of Java such as OpenJDK 11, 12, or 13. If you need a Java runtime for a desktop app you are building (such as Swing or JavaFX) you must bundle a JVM within your app using newly available tools. Oracle and the Java community no longer expect end-users to consciously install Java, so no need for JRE. Commented Aug 25, 2019 at 6:51
  • @Slaw/Basil Bourque Thanks again for these added clarifications. So "no JRE for OpenJDK 11, 12, 13": i.e. these then work perfectly well with, what, JRE 8? What about JRE 7? Could somebody point to a source where these compatibility issues are clarified? Also the other SO question I linked to in the above question says there is no JRE 11 for Windows (OpenJDK) but there is one for Linux (see the comment there in brackets). I just wish someone would document all this, as it does seem to be fairly important! Commented Aug 25, 2019 at 14:19

1 Answer 1

3

Java 8 is the default JDK (recommanded) for your System.

According to this, you need to add the repository of openjdk using this command:

sudo add-apt-repository ppa:openjdk-r/ppa

After that you need to update you index using

sudo apt-get update

If you want to install jdk 11 you can do:

sudo apt-get install openjdk-11-jdk

[Hint]

default-jdk is the default jdk. This means that, if this is up-to-date, you have the recommanded/default version of a jdk.

Also, openjdk seems to be recommanded for linux

answered Aug 24, 2019 at 13:55
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. Please see update... could you please be more explicit about what I have to do? Also I imagine you're right when you say JDK 8 is default, but the latest version appears to be higher than 1.8.0_171: oracle.com/technetwork/java/javase/downloads/…: _221, seemingly. Is this simply because the apt archives (or whatever they're called) are slightly out-of-date?
@mikerodent openjdk-11-jdk is not the repository (see my edit)
Thanks again. Tried again (see my update above): same error. Maybe I should just stick with the default version. Seems odd, though: v8 came out in 2014, v9 in 2017 and v11 a year ago.
@mikerodent My fault. You have to execute sudo apt-get update.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.