Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of Java JDK to Eclipse?

Tags:

java

eclipse

I've just installed Eclipse, after i installed the java JDK. The Getting Started guide (in Eclipse) says i should reference my JDK installation in Window>Preferences>Java>Installed JREs, but that a JRE would also work.

Select the Java > Installed JREs preference page to display the installed Java Runtime Environments. Confirm that a JRE has been detected. By default, the JRE used to run the workbench will be used to build and run Java programs. It should appear with a checkmark in the list of installed JREs. We recommend that you use a Java SDK instead of a JRE. An SDK is designed for development and contains the source code for the Java library, easing debugging.

There was already a JRE set up there (not a JDK), so i did nothing and tried to compile a Hello World (just to see what would happen). To my surprise, it compiled!

I searched a little bit and it looks like this works because Eclipse has a built-in Java Compiler. I tried debugging using the same eclipse set up, and it was also successful.

So, what is the difference between setting a JDK and JRE there? Why is it important to download the JDK, since in my default configuration Eclipse doesn't seem to use it?

like image 607
Márcio Paiva Avatar asked Jul 18 '12 06:07

Márcio Paiva


1 Answers

Probably the main difference is you get the source to all of the Java runtime libraries (with the JDK) which can be a big help. I always use the JDKs for that reason.

Also if you are debugging, this will allow you to meaningfully step into Java runtime libraries.

like image 184
Francis Upton IV Avatar answered Oct 12 '22 23:10

Francis Upton IV