Java

Java

Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture. The syntax of Java is similar to C and C++, but has fewer low-level facilities than either of them. The Java runtime provides dynamic capabilities (such as reflection and runtime code modification) that are typically not available in traditional compiled languages.

See Java on Wikipedia.

Getting started

The Pro Linux Container of Brap is pre-configured with Java. It uses Open JDK, an open-source variant of JRE and JDK packaged with Ubuntu.

To check the installed version of Java, run:

java --version

To check the installed version of Java compiler, run:

javac -v

Here is a Hello, World! program file in Java, HelloWorld.java:

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

To compile a Java program, run:

javac HelloWorld.java

To run a Java program, run:

java HelloWorld

Screenshot of Java running in the VS Code terminal

Screenshot: Hello, World! in Java running in VS Code terminal

Keywords

  • java
  • compiled
  • object oriented
  • oop

Back to top