Java Basics Part 1


Java Basics,Lets Start with understanding what is Jave?

Java is the most popular programming language & is the language of choice for Android programming ,java is platform and device independent langauge ie it can run on any computer.

Lets see what makes it possible to run on any plateform?

Here comes the JVM ,now the question may arise in your mind .what is JVM? The Java Virtual machine (JVM) is the virtual machine that run the Java bytecodes. The JVM doesn’t understand Java source code, that’s why you compile your *.java files to obtain *.classfiles that contain the bytecodes understandable by the JVM. It’s also the entity that allows Java to be a “portable language” (write once, run anywhere). Indeed there are specific implementations of the JVM for different systems (Windows, Linux, MacOS), the aim is that with the same bytecodes they all give the same results.

Now lets see what we can use to develope the java program?here comes the term   JDK And lets understand both term

JDK (Java Development Kit)

Java Developer Kit contains tools needed to develop the Java programs, and JRE to run the programs. The tools include compiler (javac.exe), Java application launcher (java.exe), Appletviewer, etc…

Compiler converts java code into byte code. Java application launcher opens a JRE, loads the class, and invokes its main method.

You need JDK, if at all you want to write your own programs, and to compile them. For running java programs, JRE is sufficient.

JRE is targeted for execution of Java files

i.e. JRE = JVM + Java Packages Classes(like util, math, lang, awt,swing etc)+runtime libraries.

JDK is mainly targeted for java development. I.e. You can create a Java file (with the help of Java packages), compile a Java file and run a java file.

JRE (Java Runtime Environment)

Java Runtime Environment contains JVM, class libraries, and other supporting files. It does not contain any development tools such as compiler, debugger, etc. Actually JVM runs the program, and it uses the class libraries, and other supporting files provided in JRE. If you want to run any java program, you need to have JRE installed in the system

The Java Virtual Machine provides a platform-independent way of executing code; That mean compile once in any machine and run it any where(any machine).

OpenJDK (Open Java Development Kit) is a free and open source implementation of the Java programming language. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License (GPL) with a linking exception

Before move on to the actuall programming methodology using Java it is necessary to understand JVM in some what details,JVM contains the JRE and JRE has different things implemented into to run the programe .lets see each one by one


ClassLoader in Java is a class which is used to load class files in Java. Java code is compiled into class file by javac compiler and JVM executes Java program, by executing byte codes written in class file. ClassLoader is responsible for loading class files from file system, network or any other source. There are three default class loader used in Java, Bootstrap , Extension and System or Application class loader

Class(Method) Area

Class(Method) Area stores per-class structures such as the runtime constant pool, field and method data, the code for methods


Heap is a runtime data area in memory where Objects, Instance variable and Arrays are stored.


Java Stack stores frames.It holds local variables and partial results, and plays a part in method invocation and return

Each thread has a private JVM stack, created at the same time as thread

A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes

Program Counter Register

PC (program counter) register. It contains the address of the Java virtual machine instruction currently being executed

Native Method Stack

It contains all the native methods used in the application

Execution Engine

It contains A virtual processor,Interpreter: Read bytecode stream then execute the instructions.Just-In-Time(JIT) compiler: It is used to improve the performance.JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term ?compiler? refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU