Introduction - History and features | Java

Xander BillaXander Billa
6 min read

Java is an object oriented, class based, concurrent, secured and general purpose computer programming language. It is considered as both interpreted and compiled language. It is used to develop web applications, web servers and application software.

  • An object is an instance of a class it is a runtime having constant state and behaviour.

  • A class is a group of objects have common properties it's a logical entity, it can also be called as a template/blueprint from which objects are created.

  • A Java class can contain field, methods, constructors, blocks, interface and nested classes.

Any hardware or software in which a program is to run is known as a platform since Java has a runtime environment that is Java runtime environment also called JRE platform to run java applications.

Example:

class Test{
    public static void main (String[] args){
        System.out.println("It's day 1!, We're Just Getting Started!");
    }
}

History

  • Java was originally designed for interactive television, but it was too advanced technology for digital cable television industry at that time. The history of Java starts with green team.

  • Initially this project developed a language for digital devices such as setup boxes, television, etc. Later Java technology was incorporated by Netscape.

  • The principal for creating Java were simple, robust portable platform independent security high performance multi threaded, architectural, neutral, object oriented, interpreted and dynamic language

  • James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language in 1991. The small team of Sun Engineers called Green Team who came with a project called Green Project. Originally designed for small embedded systems in electronic applications like setup boxes.

  • Firstly it was called "Green Talk" by James Gosling file extension was .gt

  • After that it was called oak and was developed As a part of Green Project because Oak is a symbol of strength and chosen as national tree of many countries like USA, Germany, France etc. In 1995 Oak was renamed as Java because it was already trademarked by Oak technologies.

  • Java is an island of Indonesia where first copy was produced called Java Coffee. On January 27, 2010 SUN was acquired by Oracle in $7.4 billion

  • JDK 1.0 released in January 23, 1996.

Features of Java

Simple

Java is easy to learn all its syntax is simple, clean and easy to understand because -

  • Java syntax is based on C++.

  • It has removed many complicated and rarely used features for example explicit pointers, operator loading, etc.

  • There is no need to remove unreferenced object because there is an automatic Garbage collection in Java.

Object Oriented

Object oriented means reorganize our software as a combination of different types of objects that incorporates both data and behaviour.

OR

Object Oriented Programming (OOPs) is a mythology that simplifies software development and maintenance by providing some rules.

Platform Independent

It is independent because it is different from other language like C etc while Java is a Write Once, Run Anywhere (WORA) language. A platform is the hardware or software environment in which program runs.

There are two types of platform -

  1. Software based

  2. Hardware based

Java provides software based platform. It has two components -

  • Runtime environment

  • API (Application Programming Interface)

Jama Ku is compiled by the compiler and converted into white code this white holds in platform independent code because it can be run on multiple gradients that is Write Once, Run Anywhere (WORA).

Secured

In Java we can develop virus free systems java secured because -

  • No explicit pointer, but java uses pointer implicitly: Java use pointers for manipulations of references but these pointers are not available for outside use.

  • Java around running inside a virtual machine called Sandbox

  • Classloader in Java is a part of JRE which is used to load Java classes into JVM dynamically. It adds security by separating the package for the class of local file system from those that are imported from network sources.

  • Bytecode verifier check the code fragments for illegal code that can access or violate right to object.

  • Security manager determines what resources a class can access such as reading and writing at local disk.

This Java security are by default. Some security can also be provided by an application developer explicitly through SSL, JAAS, cryptography etc.

Robust

Robust simply means strong.

  • Uses a strong memory management

  • Lack of pointer that avoids security problem

  • Automatic garbage collection in Java which run on the JVM to get rid of object which are not being used by a Java application anymore.

  • Exception handling and the type checking mechanism in Java.

Architectural Neutral

Java is architecture neutral because there are no implementation dependent feature for example the size of primitive type is fixed.

In C programming language int data types occupies 2 bytes of memory for 32 bit architecture and 4 bytes of memory for 64 bit architecture however, it occupies four bytes of memory for both 32 bit and 64 bit architecture in Java.

Portable

It facilitates you to carry the Java bytecode to any platform it doesn't require any implementation.

High Performance

It is faster than other traditional interpreted programming language because Java bytecode is "close" to native code it is still a bit slower than a compiled language example C/C++.

Distributed

RMI and EJB are used for creating distributed application this features of Java make us able to access files by calling a method from any machine on Internet.

Multi Threaded

A thread is like a separating program or smaller units of a process. We can write program that deal with many program or tasks at once by defining multiple threads.

  • It run concurrently within a single program, allowing for parallel execution of tasks.

  • Each thread represents an independent sequence of instructions, and multiple threads can exist within the same process, sharing the same resources like memory space but having their own execution flow.

  • It does not occupy memory for each thread it share a common memory area threads are important for multimedia etc.

Dynamic

Java is not typically classified as a dynamic language in the same sense as languages like Python, Ruby, or JavaScript. Java is often considered a statically-typed and compiled language. However, it does possess certain dynamic features. Let's explore these aspects:

  1. Dynamic Class Loading: Java allows for dynamic class loading at runtime. Classes can be loaded and instantiated dynamically using the Class.forName() method, enabling the creation of objects based on class names known only at runtime.

     javaCopy codeString className = "com.example.DynamicClass";
     Class<?> dynamicClass = Class.forName(className);
     Object instance = dynamicClass.newInstance();
    
  2. Reflection: Java provides reflection, a mechanism that allows a program to examine and manipulate its own structure, such as classes, methods, and fields, during runtime. This enables dynamic instantiation of classes, invocation of methods, and access to fields.

     javaCopy codeClass<?> clazz = SomeClass.class;
     Object instance = clazz.newInstance();
    
     Method method = clazz.getMethod("someMethod");
     method.invoke(instance);
    
  3. Dynamic Proxy: Java supports dynamic proxy classes through the java.lang.reflect.Proxy class. This allows the creation of proxy instances that implement one or more interfaces at runtime.

     javaCopy codeInvocationHandler handler = new MyInvocationHandler();
     SomeInterface proxyInstance = (SomeInterface) Proxy.newProxyInstance(
         SomeInterface.class.getClassLoader(),
         new Class[] { SomeInterface.class },
         handler
     );
    

Scripting API (JEP 223): Starting from Java 9, the Java platform includes the Java Shell (JShell) and the Java Scripting API, allowing for the evaluation of code snippets and scripting languages at runtime.

javaCopy codeScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
engine.eval("print('Hello, dynamic Java!')");

Conclusion

Java is a versatile, object-oriented, class-based language known for its simplicity, portability, security, and platform independence. Originally designed for interactive television, it evolved into a robust programming language used in web development and application software. With dynamic features like reflection and dynamic loading, Java provides adaptability. Its history dates back to the early 1990s, and it remains a foundational language in software development.

0
Subscribe to my newsletter

Read articles from Xander Billa directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Xander Billa
Xander Billa

Myself Vikas Singh from Varanasi, Uttar Pradesh. Learning and exploring technical domains at Acharya Institute, Bangalore (IN) from the last two years. The main goal is to learn as much domains, tool