11

I have just noticed that my Eclipse (version Luna) was running on the JRE instead of the JDK. I was wondering about that, because my environment variables are set correctly as !User-Variables! (JAVA_HOME and added into the PATH-value).

I'm not an absolute beginner, so I surely know that JDK is for developers (as the name suggests) and also includes JRE. I`m just totally amazed that Eclipse, which is built to develope, only access to the Runtime Environment.

Maybe I´m wrong and at the configuration "installed JREs" it only gets access to things like the JVM etc. and gets access to JDK at another point?!

I stumbled upon this while I´m trying to fix a problem with parameter names from standard class methods (got arg0, arg1 etc.) and saw that the javadoc was not attached.

Now I want to know if I should select JRE or JDK at Windows => Preferences => Java => Installed JREs? I dare guess that running a programm with JDK configured would slow it because the folder of JDK includes more data and therefore has a bigger size. What´s the "normal" configuration?!

I just want to configure Eclipse correctly and close my knowledge gap, I obviously have at this context.

monty.py
  • 2,511
  • 1
  • 17
  • 29
  • Look at this [Thread](http://stackoverflow.com/questions/1642338/how-does-eclipse-compile-classes-with-only-a-jre). Eclipse includes its own implementation of what is needed in JDK (compiler). The JRE is only used to run application. – Nemolovich Jan 04 '15 at 00:16

1 Answers1

17

It's probably best to configure a JDK for programming in Eclipse. Is not that a JRE won't run your program, because it will (it includes the JVM executable anyway). The thing is, using the JDK will give you access to the JDK source code (and javadoc) which is more likely what you want.

Furthermore, you may need to develop for a certain Java version, but run Eclipse with another one. That is why Eclipse lets you configure several Java JREs/JDK. Also, the JDK includes some other tools that you may eventually need (compare the executables included in one and the other). So go with the JDK and leave the JRE for the users of your program.

One last thing. There's a misconception in your statement regarding program speed execution and the size of the JDK folder. In general, the size a program takes in disk in not related with how "fast" or "slow" it would run. The speed of your program depends on too many things to be mentioned here, but in the scope of your question, it depends on the JVM executable and your code of course, and both will be the same, should you go with the JDK or the JRE.

jotadepicas
  • 2,389
  • 2
  • 26
  • 48
  • Thank you for this conceivable explanation! Another question: Is the JRE standardly selected in this configuration? – monty.py Jan 04 '15 at 01:08
  • I'm glad you find it useful, please accept it as a valid answer if you feel like it :). Regarding your comment, what do you mean by "standardly selected"? If you want to know which JVM will be used to run your program, Eclipse will use the one included in the configured JDK. Also, I prefer to separate the concepts of JDK/JRE and JVM. I think it's more accurate to say that Both JDK and JRE include a version of the JVM (your program will run in the JVM). – jotadepicas Jan 04 '15 at 01:19
  • Of cource I know this. No, I want to know if Eclipse set the JRE originally during installation, or did it maybe just found the JRE in my case, because I set the JDK only in the user variables (because my pc only have 1 user) and not in the system variables? – monty.py Jan 04 '15 at 01:38
  • Oh, sorry! I see. I'm not sure about this particular mechanism in eclipse, I guess you had the JRE in the path and/or in a system-wide JAVA_HOME variable or something like that, and eclipse found it and configured it by default. I personally don't even have a JRE installed, just a JDK and eclipse selects that by default. However, is not that important how eclipse configures itself by default, just go to the "installed JREs" and change it to whatever you need. I hope I did get your question right this time :) – jotadepicas Jan 04 '15 at 01:46