Introduction to java | Java features | JVM JRE JDK and bytecode explained


Features of Java

Java is a well known programming languages.  It has reached billions of devices. There are different features that java supports today.

But the main principles that java has since it's evolution are:
1. It must be simple, object oriented and familiar:
 When java was created there was already few well known programming languages and the most famous among them was 'c'. So they wanted syntax of java should be similar to c so that it's easy for developers to migrate to java. And it should be based on object oriented. We will learn about object oriented in subsequent blog.

2. It must be robust and secure:
 Java has built in garbage collection mechanism and you don't need to free memory explicitly. It not only removes burden of memory cleaning from developer head but also helps making application less prone to memory issues and crashing.
And java application does not run directly on native OS but it runs on a special virtual machine called JVM which makes it secure.

3. It must be architecture neutral and portable:
 There is another term coined with this principle WORA or Write Once Run Anywhere.
This principle actually means if we write our application once and create executables then we should be able to run it across platforms that is if we build our application on windows 64 then we should be able to use it on windows 32, Linux or any other devices supporting java without rebuilding it.

4. It must execute with high performance:
 Java application should be very efficient when performance comes into picture.
So basically we use byte code (we will learn about it later) which is easy to convert to machine understandable code hence java is faster as compared to other interpreted language.

5. It must be interpreted, threaded and dynamic:
 Java source codes are compiled to give bytecode which is JVM understandable. And this byte code is interpreted by JVM to machine code during execution. So java is interpreted.
Java supports multi threading and in fact it is based on threaded model so even if we don't create any thread, one main thread is created by default.
In Java object creations happens dynamically at run time. Like objects are created and loaded into memory and removed from memory dynamically.

JVM: JVM stands for Java Virtual Machine. It is responsible for interpreting java bytecode into machine understandable language and execute it.
Please Note: JVM is highly platform dependent and in turn makes java platform independent.

JRE: JRE stands for Java Runtime Environment. It consists of JVM and other java libraries and classloaders. To run any java application we require JRE. Usually when we download JRE, JVM comes along with it.

JDK: It stands Java Development Kit. It is required for developers only as it contains some tools like compiling tools, debugging tools etc. When we only require to run java application JRE is sufficient but when we are developing some java application we need to compile it, debug it and run it to test behaviour. So that time we need this tool. Usually when we download JDK, JRE and JVM comes along with it.

Bytecode: When we compile java program, it gets converted to some intermediate code which is called byte code. Itvis not understandable by native OS and only JVM can understand it and interpret it to machine understandable language.


Compiled language vs interpreted language: 
Compiled language: compiled language gets converted to machine understandable language during compilation and the tool which does compilation is called compiler. In compiled language complete program is scanned and converted to machine understandable language and then that generated code can be run on native OS.

Interpreted language: Unlike compiled language, interpreted language are scanned line by line and during runtime only it is interpreted and run. Like one line will be picked interpreted to machine language and executed then next line is picked interpreted and execute and so on. The tool which interpret is called interpreter.

Java as both compiled as well as interpreted language.
Java programs have two phases. In first phase source code is compiled to give bytecode and in second phase bytecode is interpreted by JVM and executed.


Comments

Popular posts from this blog

Tic Tac Toe game using HTML and JavaScript

Environment Setup | Install eclipse, notepad plus plus and JDK | Java programming course