Java Introduction


Java is one of the most popular programming languages in the world. It is known for being reliable, secure, and platform-independent. In simple words, you can write a Java program once and run it anywhere. This flexibility and power have made Java the backbone of many enterprise applications, Android apps, and web systems.

Let’s explore Java from the very beginning—what it is, how it works, and why it continues to be a preferred choice for developers.

What is Java?

Java is a high-level, object-oriented programming language developed by Sun Microsystems in 1995. It was created by James Gosling and his team to make a language that could run on different types of devices without needing to be rewritten. That’s where the famous slogan came from: “Write once, run anywhere.”

Java programs run inside the Java Virtual Machine (JVM), which acts as an interpreter between your code and the operating system. The JVM converts Java bytecode into machine code that your computer understands. This is what allows Java applications to be platform-independent.

History of Java

The story of Java began in 1991 with a project called “Green Project.” It was initially designed for interactive televisions and small electronic devices. But as the Internet started growing, the team realized Java could serve a much bigger purpose — web applications.

  • 1995: Java was officially released with the name “Java 1.0.”

  • 1998: Java 2 introduced new features like Swing and Collections.

  • 2006: Sun made Java open-source under the GPL license.

  • 2010: Oracle acquired Sun Microsystems, becoming the official owner of Java.

  • Present: Java continues to evolve with frequent updates (like Java 17 and 21) improving speed, security, and developer productivity.

Features of Java

Java’s success lies in its unique set of features. Let’s go through the main ones that make it stand out:

  1. Platform Independent
    Java programs are compiled into bytecode, which runs on any system with a JVM installed. You don’t have to worry about operating systems or hardware differences.

  2. Object-Oriented
    Java is based on the principles of Object-Oriented Programming (OOP), such as inheritance, encapsulation, and polymorphism. This makes it easy to organize and maintain code.

  3. Simple and Familiar
    Java was designed to be easy to learn, especially for those familiar with C or C++. Its syntax is clean and avoids confusing features like pointers or multiple inheritance.

  4. Secure
    Java has built-in security features like bytecode verification, sandboxing, and access control, which protect against unauthorized access and viruses.

  5. Robust
    It handles errors and exceptions gracefully. Java also manages memory automatically through garbage collection, reducing the risk of memory leaks.

  6. Multithreaded
    Java allows you to perform multiple tasks at the same time using threads, which makes applications faster and more responsive.

  7. High Performance
    Although Java is an interpreted language, technologies like Just-In-Time (JIT) compilation make it nearly as fast as native languages like C++.

  8. Distributed and Networked
    Java simplifies working with network connections and data sharing. It has strong APIs for building distributed applications.

How Java Works

Java’s working process can be divided into three main steps:

  1. Writing the Code
    You write the code in a .java file using a text editor or IDE (like IntelliJ IDEA, Eclipse, or NetBeans).

  2. Compilation
    The Java compiler (javac) converts the source code into bytecode, which is stored in a .class file. This bytecode is not specific to any machine.

  3. Execution
    The JVM reads the bytecode and translates it into machine code so your computer can execute it. This is what allows the same program to run on Windows, macOS, or Linux without modification.

Example workflow:

Source Code (.java) → Compiler → Bytecode (.class) → JVM → Machine Code

Java Editions

Java comes in different editions, each serving specific purposes:

  1. Java Standard Edition (Java SE) – Used for desktop and basic applications. It includes core libraries and APIs.

  2. Java Enterprise Edition (Java EE or Jakarta EE) – Used for large-scale, distributed, and web-based applications.

  3. Java Micro Edition (Java ME) – Designed for embedded systems and small devices.

  4. JavaFX – Used for creating rich Internet applications and graphical interfaces.

Setting Up Java Environment

Before writing Java programs, you need to install the Java Development Kit (JDK), which includes tools for compiling and running Java code.

Steps to set up Java:

  1. Download the JDK from Oracle’s official website.

  2. Install it on your system.

  3. Set the environment variable PATH to include the JDK’s bin directory.

  4. Verify installation by running this command in your terminal or command prompt:

    java -version
    

    If installed correctly, it will show the version of Java.

You can also use an Integrated Development Environment (IDE) like IntelliJ IDEA or Eclipse to write and run code more easily.

First Java Program

Here’s a simple example of a basic Java program:

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

Explanation:

  • class HelloWorld: Defines a class named HelloWorld.

  • public static void main(String[] args): The main method is the entry point of any Java program.

  • System.out.println(): Prints text on the screen.

How to run it:

  1. Save the file as HelloWorld.java.

  2. Open the terminal and navigate to the file’s directory.

  3. Compile the program:

    javac HelloWorld.java
    
  4. Run the compiled code:

    java HelloWorld
    

    Output:

    Hello, Java!
    

Applications of Java

Java is everywhere — from mobile apps to cloud platforms. Some common areas include:

  • Android Development: Every Android app is written in Java or Kotlin.

  • Web Applications: Frameworks like Spring and Java EE power enterprise websites.

  • Desktop Applications: Tools like Eclipse and IntelliJ are built using Java.

  • Big Data and Cloud: Used in platforms like Hadoop and Apache Spark.

  • Internet of Things (IoT): Java runs on embedded devices and smart gadgets.

Summary of the Tutorial

In this chapter, we learned that Java is a powerful, platform-independent, and object-oriented language that continues to shape modern software development. You now understand its history, features, workflow, and basic setup. In the next tutorial, we’ll dive deeper into Java Syntax, where you’ll learn the structure of a Java program and how different elements work together.


Practice Questions

  1. What is Java and why is it called platform-independent?

  2. Who developed Java and when was it first released?

  3. What is the role of the Java Virtual Machine (JVM)?

  4. What is Java bytecode and why is it important?

  5. List the main features of Java.

  6. What are the different editions of Java?

  7. Explain the steps involved in compiling and running a Java program.

  8. What is the purpose of the main() method in Java?

  9. Mention some real-world applications of Java.

  10. What are the main advantages of using Java for development?


Try a Short Quiz.

coding learning websites codepractice

No quizzes available.

Go Back Top