Swiftorial Logo
Home
Swift Lessons
Matchups
CodeSnaps
Tutorials
Career
Resources

Introduction to Java

What is Java?

Java is a high-level, class-based, object-oriented programming language designed to have as few implementation dependencies as possible. It is a widely-used programming language, especially for web and application development.

Java was created by Sun Microsystems in 1995.

Key Features of Java

  • Platform Independence
  • Object-Oriented
  • Robust and Secure
  • Multithreaded
  • High Performance

Java Architecture

Java architecture is based on the concept of the Java Virtual Machine (JVM), which allows Java to be platform-independent. The architecture can be divided into two parts:

  1. Java Development Kit (JDK)
  2. Java Runtime Environment (JRE)
The JDK is used to develop Java applications, while the JRE allows you to run them.

Installation

To install Java, follow these steps:

  1. Download the JDK from the official Oracle website.
  2. Run the installer and follow the instructions.
  3. Set the JAVA_HOME environment variable to the JDK installation path.
  4. Add the JDK's bin directory to your system's PATH variable.

Hello World Example

Here is a simple Java program that prints "Hello, World!" to the console:

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

FAQ

What is the latest version of Java?

As of October 2023, the latest version is Java 21.

Is Java free to use?

Yes, the OpenJDK version of Java is free and open-source.

What are some common uses of Java?

Java is commonly used for web applications, mobile applications (especially Android), enterprise applications, and cloud-based services.