Thursday, May 3, 2012

Difference between JDK and JRE

JDK:
         JDk means Java Development Kit. Its a bundle of soft-wares and tools that we use to develop java based softwares. JDK is needed by Java developers to develop programs and applications. the tools provided by JDK include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, Debugger etc… Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.

JRE:
        JRE means Java Run-time Edition or Java Run-time Environment. JRE is required to run any Java based software or applications. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.



The following snippet has been taken from the README.html in jdk1.6.0_03.

Contents of the JDKTM

This section contains a general summary of the files and directories in the JDKTM. For details on the files and directories, see the JDK File Structure section of the Java SE documentation for your platform.
Development Tools
(In the bin/ subdirectory) Tools and utilities that will help you develop, execute, debug, and document programs written in the JavaTM programming language. For further information, see the tool documentation.
Runtime Environment
(In the jre/ subdirectory) An implementation of the Java Runtime Environment (JRETM) for use by the JDK. The JRE includes a JavaTM Virtual Machine (JVMTM), class libraries, and other files that support the execution of programs written in the JavaTM programming language.
Additional Libraries
(In the lib/ subdirectory) Additional class libraries and support files required by the development tools.
Demo Applets and Applications
(In the demo/ subdirectory) Examples, with source code, of programming for the JavaTMTM Foundation Classes, and the JavaTM Platform Debugger Architecture. platform. These include examples that use Swing and other Java
Sample Code
(In the sample subdirectory) Samples, with source code, of programming for certain Java API's.
C header Files
(In the include/ subdirectory) Header files that support native-code programming using the Java Native Interface, the JVMTM Tool Interface, and other functionality of the JavaTM platform.
Source Code
(In src.zip) JavaTM programming language source files for all classes that make up the Java core API (that is, sources files for the java.*, javax.* and some org.* packages, but not for com.sun.* packages). This source code is provided for informational purposes only, to help developers learn and use the JavaTM programming language. These files do not include platform-specific implementation code and cannot be used to rebuild the class libraries. To extract these file, use any common zip utility. Or, you may use the Jar utility in the JDK's bin/ directory:
jar xvf src.zip

The Java Runtime Environment (JRETM)

The JavaTM Runtime Environment (JRETM) is available as a separately downloadable product. See the download web site.
The JRE allows you to run applications written in the JavaTM programming language. Like the JDKTM, it contains the JavaTM Virtual Machine (JVMTM), classes comprising the JavaTM platform API, and supporting files. Unlike the JDK, it does not contain development tools such as compilers and debuggers.
You can freely redistribute the JRE with your application, according to the terms of the JRE license. Once you have developed your application using the JDK, you can ship it with the JRE so your end-users will have a JavaTM platform on which to run your software.

The following video may also help.