ADVERTISEMENTS

What is Java ?

Java is a high-level, object-oriented programming language that was first released by Sun Microsystems (now owned by Oracle Corporation) in 1995. It is designed to be platform-independent, meaning that Java code can be run on any computer or device that has a Java Virtual Machine (JVM) installed.

Java is known for its "write once, run anywhere" (WORA) philosophy, which means that Java code can be written once and run on multiple platforms without the need for any changes. This is made possible by the JVM, which interprets Java bytecode and executes it on the underlying hardware.

Java is widely used for developing a variety of applications, including web applications, mobile applications, desktop applications, and enterprise software. Some of the key features of Java include:

  • Object-oriented programming model
  • Garbage collection
  • Strong type checking
  • Platform independence
  • Multi-threading support
  • Exception handling
  • Security features

Java has a large and active community of developers and is supported by a rich ecosystem of tools and libraries, making it a popular choice for building a wide range of applications.

ADVERTISEMENTS

Java Platforms / Editions

There are several editions of Java, each targeting a specific platform or use case:

  • Java SE (Standard Edition) : This is the most common edition of Java and is used for developing desktop, server, and general-purpose applications. It includes the core libraries and runtime environment that are needed to run Java applications.
  • Java EE (Enterprise Edition) : This edition of Java is used for developing large-scale, distributed, and enterprise-level applications. It includes additional libraries and APIs for working with web services, messaging, and other enterprise technologies.
  • Java ME (Micro Edition) : This edition of Java is used for developing applications for small, embedded devices such as mobile phones, PDAs, and other consumer devices.
  • Java FX : This is a platform for building rich, interactive applications that can run on desktops, browsers, and mobile devices.

In addition to these main editions, there are also a number of specialised editions of Java, such as Java Card for developing smart card applications and Java TV for developing applications for digital television.

Each edition of Java has its own set of APIs and libraries, but all editions share the same core language syntax and runtime environment, making it easy to transfer skills and code between different platforms.

Java Example

Here's an example of a simple Java program that prints the message "Hello, world!" to the console:

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

Let's break down the different parts of this program:

  • public class HelloWorld : This line defines a new class called HelloWorld. In Java, every program must have at least one class, and the name of the file that contains the class must match the name of the class.
  • public static void main(String[] args) : This line defines a special method called main that serves as the entry point for the program. When the program is run, the main method is the first method that is executed.
  • System.out.println("Hello, world!"); : This line prints the message "Hello, world!" to the console. In Java, the System.out object represents the standard output stream, and the println() method is used to print a string to the console.

To run this program, save it to a file called HelloWorld.java and compile it using the javac command:

javac HelloWorld.java

This will create a new file called HelloWorld.class, which contains the compiled bytecode for the program. To run the program, use the java command:

javac HelloWorld.java

This will execute the main method of the HelloWorld class and print the message "Hello, world!" to the console.

ADVERTISEMENTS