1

I am having java JDK version 11 and JRE version 8, it will occur any problem in feature or not? is it mandatory to have same jdk version and jre version?

  • 4
    Possible duplicate of [JDK, JRE, Java: Version Confusion!](https://stackoverflow.com/questions/4696611/jdk-jre-java-version-confusion) – Duck Dodgers Jan 29 '19 at 09:30

4 Answers4

2

If your code is using features of Java 11, you will need the JRE 11 to run it. But as long as you develop your code against JRE 8, it doesn't matter which JDK you use to develop and compile with.

You can set your project in your IDE to a compatibility level of JRE 8 (like here). This prevents any usage of features newer than Java 8.

Example: Develop with JDK 11 but only use features from Java 8 -> code will run in JRE 8. See the older versions as subsets of the newer ones.

bkis
  • 2,196
  • 1
  • 13
  • 22
1

If you compile code targeting Java 8, and don't use any newer APIs, you can run it on either.

If you build for Java 11, but try to run on Java 8 it won't work.

The simplest thing to do is to use the JVM the software was built on (or a newer version)

Peter Lawrey
  • 498,481
  • 72
  • 700
  • 1,075
0

No. Because you never use both of them at the same time.

talex
  • 15,633
  • 2
  • 24
  • 56
0

JRE is Subset of JDK.

JDK includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler (javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java development.

If you Open your JDK folder (C:\Program Files\Java\jdk1.8.0_152) , you can find JRE there.

Coming to your Question; No it is not necessary to have both JDK and JRE of same version as we don't use both at the same time.

Community
  • 1
  • 1
Vishwa Ratna
  • 4,468
  • 4
  • 24
  • 46
  • I think the question is about the versions of JRE and JDK and the compatibility of the code you write with certain JREs. – bkis Jan 29 '19 at 09:46
  • I saw that. I just don't understand the reason you are giving. With each version, there are language features added to Java. If you use those in your code, the JRE it's supposed to run on has to be able to interpret it. What has "using both at the same time" to do with that? I'm not complaining here - no offense, i'm just curious because i don't understand it. – bkis Jan 29 '19 at 10:18
  • `using both at the same time` i mean by it that you can right away remove JRE explictly , try just configuring JDK and you are fine with it. JDK itself contain JRE. – Vishwa Ratna Jan 29 '19 at 10:24
  • @mumpitz FYI : https://stackoverflow.com/questions/32988601/do-i-need-both-jdk-and-jre – Vishwa Ratna Jan 29 '19 at 10:25
  • Ah, i understand. You mean if you run the application on the same machine you are developing on? But what if someone else runs your program and only has a jre? The version has to be sufficient here. – bkis Jan 29 '19 at 10:26
  • @mumpitz , anyways you will configure your Environment variables, so dont you think JDK will be configured there?? so why to think of JRE again?? – Vishwa Ratna Jan 29 '19 at 10:27