1

I had only a JRE and now I also downloaded a JDK; they are listed in control panel as:

Java 8 update 121, Java SE Development Kit 8 Update 121 so I guess the JRE inside my JDK and the other JRE are the same version;

When I write in cmd java -version; is it the original jre or the jre inside the jdk's folder?

Also i was thinking, considering i have 2 identical JRE, can i delete the old one or is it bad practice?

wattbatt
  • 447
  • 2
  • 13

2 Answers2

1

It relates to whatever's first on your path, simple as that. Every executable follows the same resolution rules.

On unix, you can use this to see where it's coming from

which java

On Windows it's

where java
Michael
  • 41,989
  • 11
  • 82
  • 128
0

java -version tells the JDK version and yes, you should only keep the latest production version of JRE and JDK in the system. No need for having multiple libraries as any application can have only one JRE associated with it.

jsgrewal12
  • 128
  • 9
  • nice; in case an ide or some other application says there is no JRE all i have to do is just link the path of the JRE inside JDK's folder right? – wattbatt May 01 '20 at 09:43
  • no installing java not necessarily installing jdk it is telling just java runtime. – silentsudo May 01 '20 at 09:45
  • Which IDE you prefer? Generally IntelliJ or Eclipse will ask you for the location of JRE or auto-detect it through the `%PATH%` variable. – jsgrewal12 May 01 '20 at 09:46
  • @jsgrewal12 Eclipse; I checked and it was using the jre inside jdk's folder so no problem; maven too so i should be okay with the important stuff; but now `java -version` is not recognised by cmd; as long as my codes work not a big problem i hope – wattbatt May 01 '20 at 09:55
  • 1
    Hey @wattbatt "If the code works, deploy it" is the rule. Anyways in case, it is not being recognized by cmd you would want to check if your Environment Variable `path` contains the address to your `javac.exe`. In my case, the path is `C:\Program Files\Java\jdk-10.0.1\bin`. Just add it to the path and restart the PC. CMD will recognize the version. Try it and tell me if you face any issues. – jsgrewal12 May 01 '20 at 10:06
  • @jsgrewal12 yes it works, transition complete then, good. I didn't like the idea of having 2 copies of the same thing on my pc, I understood only later that jdk comes with a jre inside – wattbatt May 01 '20 at 10:15
  • Upvote the answer if it helped you so that it can help others in the community too. And we learn a lot from these small things so you should feel good about this learning. Thanks – jsgrewal12 May 01 '20 at 10:19