JAVA Basics | History

date
Apr 27, 2024
slug
java
status
Published
tags
Java
Java History
Java Basic
summary
Discover Java's evolution, principles, and applications. Java history, James Gosling, Sun Microsystems, open-source, virtual machine, simplicity, robustness, security, high performance.
type
Post
Hello Everyone, first of fall, thanks for visiting this website.Hello Everyone, first of fall, thanks for visiting this website.
Hello Everyone, first of fall, thanks for visiting this website.

Introduction to JAVA

Quick intro of JAVA

  • Java is an object-oriented, class-based, secured, platform-independent, and general-purpose programming language.
  • Java was originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of sun microsystem’s java platform.
  • Java programming language is based on the write once, run anywhere (WORA) principle.
  • Java application are typically compiled to byte code that can run on any java virtual Machine (JVM) regardless of the underlying operating system.

History

  • Java is created in 1991 by James Gosling, Mike Sheridan, and Patrick Naughton.
  • Released publicly by Sun Microsystems in 1996 as Java 1.0.
  • Originally designed for no-cost run-times on various platforms.
  • Java 1.0 compiler rewritten in java by Arthur Van Hoff.
  • Java 2 introduced with configurations for different platforms.
  • Sun Microsystems attempted to formalize Java as an ISO standard in 1997, but withdrew later.
  • Sun made most Java Implementations available for free, but revenue come from specialized product licenses.
  • Open-sourced much of Java’s virtual machine in 2006, finalized in 2007.
  • Java’s Principles: simple, robust, secure, high-performance, portable, multi-threaded, interpreted, dynamic.
  • Developed by James Gosling, Known as the Father of Java.
  • Used in mobile devices, internet programming, games, e-business, etc.

Implementation of a java Application

  1. Creating the program.
  1. Compiling the program.
  1. Running the program.
Before starting, ensure JDK is installed, and its path is set.
Creating Program:
  • Use a Text Editor (e.g., Notepad) or an IDE (e.g., NetBeans).
  • Example :
    • class Sample { public static void main(String []args){ System.out.println("My First Java Program"); } }
  • Save the file: File → Save → d:\Sample.java
Compiling the Program:
  • Run the Java compiler (javac) on Command Prompt.
    • Example: javac Sample.java
  • If successful, it creates a file called Sample.class containing byte code.
Running the program:
  • Use the Java Interpreter to execute the program.

Java programming language is named JAVA. Why?

  • Java programming language named JAVA
  • Previously named OAK
  • Team wanted new name reflecting technology essence
  • Considered names: Silk, Jolt, revolutionary, DNA, dynamic, etc.
  • Chose Java along with Silk as top contenders
  • Chosen by James Gosling
  • Named after Java island in Indonesia
  • First coffee (Java coffee) produced there
  • Gosling chose the name while having coffee near the office
  • Java is just a name, not an acronym

Java Terminology

  1. Java Virtual Machine (JVM): Executes Java bytecode.
      • Writing: Done by programmers.
      • Compilation: Done by JAVAC compiler, produces bytecode.
      • Running: JVM executes bytecode.
      • Platform-independent: Same output across different OS.
      How JVM Works – JVM Architecture?
      notion imagenotion image
      • JVM (Java Virtual Machine) runs Java applications.
      • It calls the main method in Java code.
      • Part of JRE (Java Runtime Environment).
      • Java applications follow WORA (Write Once, Run Anywhere).
      • Developed code can run on any Java-enabled system.
      • Achieved through JVM.
      • Compiling a .java file creates .class files with byte-code.
      • .class files undergo steps during runtime.
      • These steps form the JVM.
  1. Bytecode: Compiled from Java source, .class file, viewable with tools like javap.
  1. Java Development Kit (JDK): Complete development package.
      • Includes compiler, JRE, debuggers, docs.
      • Necessary for creating, compiling, running Java programs.
  1. Java Runtime Environment (JRE): Included in JDK.
      • Enables running Java programs, but not compilation.
      • Includes browser, JVM, applet support, plugins.
  1. Garbage Collector: Manages memory, recollects unreferenced objects.
      • Automates memory management, but programmers should monitor long-term object usage.
  1. ClassPath: File path for .class files, where runtime and compiler search.
      • Default libraries provided by JDK, external libraries can be added.

Primary Features of Java

  1. Platform Independent:
      • Code compiles to bytecode.
      • Bytecode runs on any platform (Windows, Linux, macOS).
      • JVM executes bytecode uniformly.
  1. Object-Oriented:
      • Programs organized into objects.
      • Key concepts: Abstraction, Encapsulation, Inheritance, Polymorphism.
  1. Simplicity:
      • Lacks complex features like pointers, operator overloading, etc.
  1. Robustness:
      • Detects errors early.
      • Features: Garbage collection, Exception Handling, Memory allocation.
  1. Security:
      • No pointers, preventing out-of-bound array access.
      • Secure environment independent of OS.
  1. Distributed:
      • Supports distributed applications.
      • Uses Remote Method Invocation and Enterprise Java Beans.
  1. Multithreading:
      • Allows concurrent execution for CPU optimization.
  1. Portability:
      • Code written on one machine runs on any other.
  1. High Performance:
      • Reduced runtime overhead.
      • Utilizes JIT compiler for faster execution.
  1. Dynamic Flexibility:
      • OOP allows for class and method additions.
      • Supports native methods from other languages.
  1. Sandbox Execution:
      • Programs run separately, ensuring system safety.
      • Bytecode verifier enhances security.
  1. Write Once Run Anywhere (WORA):
      • 'Class' files are architecture-neutral.
      • Widely used in global IT industry.
  1. Compilation and Interpretation Power:
      • Combines compilation to bytecode with interpretation by JVM.

IMPORTANT POINTS OF JAVA

  • Java is a popular programming language, introduced in 1995.
  • It's platform-independent, meaning code can run on any device with a Java Virtual Machine (JVM).
  • Code is compiled into bytecode, then executed by the JVM.
  • “Write once, run anywhere” philosophy makes it great for cross-platform development.
  • Automatic memory management through garbage collection simplifies coding.
  • Offers a vast standard library for various tasks.
  • Widely used in enterprise apps, web, and Android development.
  • Strongly typed; variables must have declared types.
  • Exception handling for managing errors.
  • Supports multithreading for concurrent tasks.

Advantages

  • Platform independence enables running code across different devices.
  • Object-oriented principles: encapsulation, inheritance, and polymorphism.
  • Built-in security features like automatic memory management and type checking.
  • Large, active developer community for support.
  • Ideal for enterprise-level applications like web and database systems.

Disadvantages

  • Performance may lag compared to languages like C++.
  • Automatic memory management can lead to slower performance and higher memory usage.
 

C++ Vs Java

TOPIC
C++
Java
Memory Management
Use of pointers, structures, union
No use of pointers. Supports references, thread and interfaces.
Libraries
Comparatively available with low-level functionalities
Wide range of classes for various high-level services
Multiple Inheritance
Provide both single and multiple inheritance.
Multiple inheritances is partially done through interfaces
Operator Overloading
Supports operator overloading
It doesn’t support this feature
Program Handling
Functions and variables can reside outside classes.
Functions and variables reside only in classes, packages are used.
Portability
Platform dependent, must be recompiled for different platform
Platform independent, byte code generated works on every OS.
Thread Support
No built-in support for threads, depends on libraries.
It has built-in thread support.

Python Vs Java

TOPIC
Java
Python
Compilation process
Java is both compiled and interpreted language, which is first compiled and then interpreted into a byte code.
Python is an interpreted programming language
Code Length
Longer lines of code as compared to python.
3-5 times shorter than equivalent Java programs.
Syntax Complexity
Define particular block by curly braces, end statements by ;
No need of semi colons and curly braces, uses indentation
Ease of typing
Strongly typed, need to define the exact datatype of variables
Dynamic, no need to define the exact datatype of variables.
Speed of execution
Java is much faster than python in terms of speed.
Expected to run slower than Java programs
Multiple Inheritance
Multiple inheritance is partially done through interfaces
Provide both single and multiple inheritance

JDK in Java

  • JDK: Software development environment for Java
  • Contains tools and libraries for Java app development
  • Cross-platform: Works on different operating systems
  • Core package with JVM and JRE
  • JVM: Executes Java programs
  • JRE: Needed to run Java programs
  • JDK vs. JRE confusion for beginners
  • JRE sufficient for running Java programs
  • JDK necessary for Java app development
  • Includes additional tools for development
JDK=JRE+Development Tools
notion imagenotion image

JDK implements Java Platform:

  • Standard Edition (Java SE),
  • Enterprise Edition (Java EE),
  • Micro Edition (Java ME).
Contents of JDK include:
  • Java Runtime Environment (JRE),
  • Interpreter/loader (Java),
  • Compiler (javac),
  • Archiver (jar), and more.
JDK's Private Runtime contains:
  • Private Java Virtual Machine (JVM),
  • Class libraries,
  • Additional useful libraries like internationalization and IDL libraries.

Components of JRE

1. Deployment Tools: These help in deploying Java applications through methods like Java Web Start and Java Plug-in. 2. User Interface Toolkits: Tools for creating interfaces, like AWT and Swing, as well as for handling graphics, accessibility, printing, sound, and drag-and-drop features. 3. Integration Libraries: These assist in integrating Java with other technologies, including databases (JDBC), naming services (JNDI), remote method invocation (RMI), and scripting. 4. Base Libraries: Essential functionalities like international support, input/output operations, management, security, and XML processing. 5. Lang and Util Libraries: Core utilities for language operations, management, versioning, zip handling, reflection, collections, concurrency, logging, preferences, and regular expressions. 6. Java Virtual Machine (JVM): The core engine that executes Java programs, including different versions for client and server environments.
If you have any questions, please contact me.