You are on page 1of 6

JDK

Java Development Kit is the core component of Java Environment and provides
all the tools, executables and binaries required to compile, debug and execute a
Java Program. JDK is a platform-specific software and that’s why we have
separate installers for Windows, Mac, and Unix systems. We can say that JDK
is the superset of JRE since it contains JRE with Java compiler, debugger, and
core classes. The current version of JDK is 11 also known as Java 11.

The Java Development Kit comes with the collection of tools that are used for developing and
running Java Programs. They Include:
• appletviewer – for viewing java applets, enable us to run java applets
• javac - Java compiler, which translates java source code to bytecode files that the interpreter can
understand.
• java – Java interpreter, which runs applets and applications by reading and interpreting bytecode
files.
• javap - java disassembler, which enable us to convert bytecode files into a program description.
• javah - for C header files, produces header files for use with native methods.
• javadoc - for creating HTML documents,
• jdb - Java debugger, which help us to find errors in our programs.

Or

Java Development kits(java software:jdk1.6): Java development kit comes with a


number of Java development tools. They are:
(1) Appletviewer: Enables to run Java applet.
(2) javac: Java compiler.
(3) java : Java interpreter.
(4) javah : Produces header files for use with native methods.
(5) javap : Java disassembler.
(6) javadoc : Creates HTML documents for Java source code file.
(7) jdb : Java debugger which helps us to find the error.
JVM

JVM is the heart of Java programming language. When we run a program, JVM
is responsible for converting Byte code to the machine specific code. JVM is
also platform dependent and provides core java functions like memory
management, garbage collection, security etc. JVM is customizable and we can
use java options to customize it, for example allocating minimum and maximum
memory to JVM. JVM is called virtual because it provides an interface that
does not depend on the underlying operating system and machine hardware.
This independence from hardware and the operating system is what makes java
program write-once-run-anywhere.

JVM(Java Virtual Machine)


The concept of Write-once-run-anywhere (known as the Platform independent) is one
of the important key feature of java language that makes java as the most powerful
language. Not even a single language is idle to this feature but java is closer to this
feature. The programs written on one platform can run on any platform provided the
platform must have the JVM(Java Virtual Machine). A Java virtual machine (JVM) is a
virtual machine that can execute Java bytecode. It is the code execution component of
the Java software platform.

JRE

JRE is the implementation of JVM, it provides a platform to execute java


programs. JRE consists of JVM and java binaries and other classes to execute
any program successfully. JRE doesn’t contain any development tools like java
compiler, debugger etc. If you want to execute any java program, you should
have JRE installed but we don’t need JDK for running any java program.

JDK vs JRE vs JVM

Let’s look at some of the important difference between JDK, JRE, and JVM.

1. JDK is for development purpose whereas JRE is for running the java
programs.
2. JDK and JRE both contains JVM so that we can run our java program.
3. JVM is the heart of java programming language and provides platform
independence.
public
This is the access modifier of the main method. It has to be public so that java
runtime can execute this method. Remember that if you make any method non-
public then it’s not allowed to be executed by any program, there are some access
restrictions applied. So it means that the main method has to be public. Let’s see
what happens if we define the main method as non-public.

Public Access Modifier - public:


A class, method, constructor, interface etc declared public can be accessed from any
other class. Therefore fields, methods, blocks declared inside a public class can be
accessed from any class belonging to the Java Universe.
However if the public class we are trying to access is in a different package, then the
public class still need to be imported.
Because of class inheritance, all public methods and variables of a class are inherited
by its subclasses.

static
When java runtime starts, there is no object of the class present. That’s why the
main method has to be static so that JVM can load the class into memory and call
the main method. If the main method won’t be static, JVM would not be able to call it
because there is no object of the class is present. Let’s see what happens when we
remove static from java main method.

void
Java programming mandates that every method provide the return type. Java main
method doesn’t return anything, that’s why it’s return type is void. This has been
done to keep things simple because once the main method is finished executing,
java program terminates. So there is no point in returning anything, there is nothing
that can be done for the returned object by JVM. If we try to return something from
the main method, it will give compilation error as an unexpected return value.

main
This is the name of java main method. It’s fixed and when we start a java program, it
looks for the main method. 
String[] args
Java main method accepts a single argument of type String array. This is also called
as java command line arguments. Let’s have a look at the example of using java
command line arguments.

The main line: the line “ public static void main(String args[]) “ defines a method name
main. Java application program must include this main. This is the starting point of the
interpreter from where it starts executing. A Java program can have any number of
classes but only one class will have the main method.
(4) Public: This key word is an access specifier that declares the main method as
unprotected and therefore making it accessible to the all other classes.
(5) Static: Static keyword defines the method as one that belongs to the entire class
and not for a particular object of the class. The main must always be declared as
static.
(6) Void: the type modifier void specifies that the method main does not return any
value.

How is Java platform independent?


The meaning of platform independent is that, the java source code can run on all
operating systems.
A program is written in a language which is a human readable language. It may
contain words, phrases etc which the machine does not understand. For the source
code to be understood by the machine, it needs to be in a language understood by
machines, typically a machine-level language. So, here comes the role of a compiler.
The compiler converts the high-level language (human language) into a format
understood by the machines. Therefore, a compiler is a program that translates the
source code for another program from a programming language into executable
code.
This executable code may be a sequence of machine instructions that can be
executed by the CPU directly, or it may be an intermediate representation that is
interpreted by a virtual machine. This intermediate representation in Java is the Java
Byte Code.
Step by step Execution of Java Program:
 Whenever, a program is written in JAVA, the javac compiles it.
 The result of the JAVA compiler is the .class file or the bytecode and not the
machine native code (unlike C compiler).
 The bytecode generated is a non-executable code and needs an interpreter to
execute on a machine. This interpreter is the JVM and thus the Bytecode is executed
by the JVM.
 And finally program runs to give the desired output.

In case of C or C++ (language that are not platform independent), the compiler
generates an .exe file which is OS dependent. When we try to run this .exe file on
another OS it does not run, since it is OS dependent and hence is not compatible
with the other OS.
Java is platform independent but JVM is platform dependent
In Java, the main point here is that the JVM depends on the operating system – so if
you are running Mac OS X you will have a different JVM than if you are running
Windows or some other operating system. This fact can be verified by trying to
download the JVM for your particular machine – when trying to download it, you will
given a list of JVM’s corresponding to different operating systems, and you will
obviously pick whichever JVM is targeted for the operating system that you are
running. So we can conclude that JVM is platform dependent and it is the reason
why Java is able to become “Platform Independent”.
Important Points:
 In the case of Java, it is the magic of Bytecode that makes it platform
independent.
 This adds to an important feature in the JAVA language termed as portability. Every
system has its own JVM which gets installed automatically when the jdk software is
installed. For every operating system separate JVM is available which is capable to
read the .class file or byte code.
 An important point to be noted is that while JAVA is platform-independent
language, the JVM is platform-dependent. Different JVM is designed for different OS
and byte code is able to run on different OS.

The concept of Write-once-run-anywhere (known as the Platform independent) is one of the


important key feature of java language that makes java as the most powerful language. Not even a
single language is idle to this feature but java is closer to this feature. The programs written on one
platform can run on any platform provided the platform must have the JVM.

You might also like