Introduction to Java

Java is a programming language and a platform. Java is a high-level, robust, object-oriented and secure programming language.

Java was developed by Sun Microsystems (which is now a subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java. Before Java, its name was Oak. Since Oak was already a registered company, James Gosling and his team changed the name from Oak to Java.

Java Editions

  • Java Standard Edition (SE): the core Java platform. It contains all of the libraries that every Java developer must learn.

  • Java Enterprise Edition (EE): used for building very large-scale, distributed systems. It’s built on top of Java SE and provides additional libraries for building fault-tolerant, distributed multi-tier software.

  • Java Micro Edition (ME): a subset of Java SE, designed for mobile devices. It also has libraries specific to mobile devices.

  • Java Card: used in smart cards.

History of java

https://www.javatpoint.com/history-of-java

Installing Java

Before diving into the world of Java programming, you need to have it installed on your machine. Here's a simple guide to get you started:

For Windows:

  1. Visit the official Java SE Downloads page.

  2. Choose the appropriate version for your operating system (32-bit or 64-bit).

  3. Download the installer and follow the on-screen instructions to complete the installation.

For Mac:

  1. You can use Homebrew to install Java on your Mac. Open your terminal and run the command: brew install openjdk.

  2. Follow the instructions provided by Homebrew to complete the installation.

For Linux:

  1. You can install Java using the package manager specific to your distribution. For example, on Ubuntu, you can use: sudo apt-get install default-jdk.

  2. Follow the prompts to complete the installation.

Running Your First Java Program

Once Java is installed, you can run a simple program to ensure everything is set up correctly. Follow these steps:

  1. Open a text editor and write a simple Java program. For example:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}
  1. Save the file with a .java extension, e.g., HelloWorld.java.

  2. Open your terminal or command prompt and navigate to the directory where you saved the file.

  3. Compile the program using the command: javac HelloWorld.java.

  4. Run the compiled program with: java HelloWorld.

If everything is set up correctly, you should see the output: Hello, Java!

How Java Code Is Executed

Java follows a two-step process of compilation and interpretation, which sets it apart from some other programming languages.

  1. Compilation: Java source code is compiled into an intermediate form called bytecode. This bytecode is platform-independent and can be executed on any device with a Java Virtual Machine (JVM).

  2. Interpretation: The JVM interprets the bytecode and translates it into machine code, allowing the program to run on the specific hardware.

This approach provides the "write once, run anywhere" capability that makes Java so popular for cross-platform development.

What are JDK, JRE and JVM

https://www.programiz.com/java-programming/jvm-jre-jdk