Introduction to Java

James Gosling from Sun Microsystems was the creator of the programming language Java who developed it in 1991.The main utility of Java is that a program is written once and it can be run on multiple OS.


The 1st version of Java that was publicly available was Java 1.0 that came out in the year 1995. Oracle Corporation acquired Sun Microsystems in 2010 and got hold of Java on its own. Sun Microsystems had made Java available under the GNU GPL (General Public Licence) in 2006 and Oracle has continued this project under the name OpenJDK.

 

Downloading Java software gets you the program in the form of JRE (Java Runtime Environment). It consists of the Java platform core classes, JVM (Java Virtual Machine) and supporting libraries. The runtime portion of the Java software is JRE that is required to run the software in the web browsers. Java consists of a programming language, core libraries, a compiler and a JVM (runtime). The runtime provides the flexibility to write the codes in any programming language other than Java that can still run on the JVM.

 

These are the properties of Java programming language:

  • Java is an ‘Object-orientated’ programming language where all the elements are objects, except the primitive data types.
  • Java programming language is ‘Platform independent’. Since Java programs do not access the OS directly, it makes them highly portable. A Java can be run on all supported platforms, whether Linux or Windows if it follows certain rules and is standard-compliant.
  • Java supports automatic memory management wherein it manages the memory allocation and de-allocation for creating new objects.
  • Java is a strongly-typed programming language, that means that the types of the used variables must be pre-defined and conversion to other objects is relatively strict.
  • Java is an interpreted and compiled language The source code in Java is transferred into the bytecode format that will be interpreted by the JVM. A Hotspot Compiler is the JVM translates the bytecode instructions into native code instructions.

 

What makes Java more valuable than other programming languages?

  • Bytecode makes Java more secure
    Whenever a programmer compiles a program, a class file with Bytecode is created by Java. The class files are tested by the JVM before execution for malware and viruses.

 

  •  Exception handling concept
    Exception handling in Java helps the programmers to get away with the risk of crashing the system.

 

  • Type-safe reference casting in JVM
    Java Virtual Machine monitors you whenever you use an object reference. The cast is deemed invalid if the programmer tries to cast a reference to a different type.

 

  •  Security Model
    The security model of Java intends to protect and help the programmers from intimidating programs downloaded from untrusted sources on the internet or within a network through its ‘Sandbox’ that allows all programs to run inside itself, preventing any reading or writing action on the local disks.

 

  •  Access Control functionality
    Java has access control functionality that comes in quite handy in preventing access to critical objects from untrusted codes.

 

  •  No use of pointers
    Use of pointers may cause unauthorized access to memory blocks when the other programs get the values of the pointers; while c and c++ use pointers, java doesn’t. The reason behind this is that Java has its own internal mechanism for management of memory and it gives access to the program data only if it has an appropriately verified authorization.

 

  •  Tested code re-usability
    While developing Java Enterprise applications, the coders can re-use the code that has already been tested. ‘Programming by Contract’ concept is a great feature of Java.

 

  •  Garbage collection mechanism
    It is yet another addition to the security features of Java. Garbage collection mechanism aids the developers to ensure the integrity of their programs at the time of executions, so as to avoid any JVM crashes because of incorrect memory freeing. In this process, Java automatically manages the storage allocation and cuts the need for manual action.

 

  •  Execution in a defined order
    In Java, all the operations are defined in a specific order of execution while all the primitives are defined with a predefined size.

 

  •  Protection from security attacks
    Any method or class declared as FINAL cannot be overridden. So, if the developers declare the method or class as final, it protects the code from security attacks that may include various override methods, creating a sub-class and replacing it with the original class.