Professional Documents
Culture Documents
JDB - Java Debugger, Which Help Us To Find Errors in Our Programs
JDB - Java Debugger, Which Help Us To Find Errors in Our Programs
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
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.
JRE
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.
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.
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.