Article

Java Guide

By MARTIN Published | Last updated

Introduction to Java


Java is an object-oriented programming language developed by Sun Microsystems (now owned by Oracle Corporation) in 1995. The language is high-level, meaning its code structure is relatively easier to read and write compared to others. The language is portable, meaning it supports many operating systems and hardware architectures, as illustrated by Sun Microsystems’ slogan, “Write once, run anywhere,” which was a game-changing achievement for its time. The “anywhere” mentioned is possible thanks to the Java Virtual Machine (JVM), a software that translates the abstract Java code a developer writes to code the particular device understands.


Java is a popular choice for open-source software development, driven by several key factors: the approachability of the language itself being high-level, the high availability of online documentation and help, its thriving and vast ecosystem of open-source libraries and frameworks for projects to implement, and that it’s stable, actively maintained and continues to evolve positively. It’s also worth reinforcing that having experience with the language is a marketable skill in the job market.

Java Platform Components


The Java platform can be broken down into these key components:


Java Virtual Machine (JVM)

Interprets compiled Java bytecode (.class files inside .jar files) and translates it into machine code the host system can execute. The JVM is also responsible for managing memory, garbage collection, and more. While Java applications are platform-independent, each JVM is written for a specific operating system and architecture (ex. Linux x86_64, macOS on Apple Silicon, or Windows 11 on Arm64).


Java Runtime Environment (JRE)

A software bundle including the JVM and other libraries necessary to run Java applications on a host system.


Java Development Kit (JDK)

A software bundle including the JRE and tools to develop Java applications, such as the Java compiler (javac).


Java API / Core Library

The pre-written Java code (classes, interfaces, and methods) for developers. For example, the java.lang package contains fundamental classes and interfaces like Object, String, Integer, Boolean, and various exceptions like ClassNotFoundException. There are more advanced packages related to time, regex, and much more too.

Versions


The current versioning system of Java is based on a release model including both LTS (Long-Term Support) and non-LTS releases.

Non-Long-Term Support - Non-LTS

Oracle releases a new non-LTS Java version every six months including new features, improvements, and bug fixes. When a new non-LTS is released, the old one will no longer be supported. No support means there won’t be additional updates or fixes for that version.

Long-Term Support - LTS

Oracle aims to release a new LTS Java version every two years that only receives quarterly security, stability, and performance updates. LTS releases lag behind in gaining the latest non-LTS features but make up for it in increased stability and extended support.


An up-to-date timeline for LTS and non-LTS versions of Java can be viewed on Oracle’s website. Read more about versions here.

Vendors


While Oracle is the primary owner and developer of the Java programming language and platform, other companies and open-source communities also develop and distribute their custom versions of Java.


Many users opt for a non-Oracle vendor for improved performance and to avoid their restrictive and circumstantially expensive licensing. A popular vendor with permissive licensing is Adoptium. However, each vendor has various levels of support, compatibility, and enterprise features, necessitating users to compare alternatives like Amazon Corretto and Azul.

Installation


Vendors provide different installation instructions for each host configuration. The following are popular options.


VendorDownload Instructions
Oraclehttps://www.java.com/en/download/help/download_options.html
Adoptium (formerly known as AdoptOpenJDK)https://adoptium.net/installation/
Microsoft Build of OpenJDKhttps://learn.microsoft.com/en-us/java/openjdk/install
Amazon Correttohttps://aws.amazon.com/corretto/
Azul Systemshttps://www.azul.com/downloads/

Developing with Java


While one could program Java applications with a plain text editor and JDK tools, it would be a painful experience. The solution is to use an integrated development environment (IDE) for Java, which provides real-time error checking and highlighting, code completion, automatic formatting, code analysis, build tools, and more.


The following are popular Java IDE options:

DeveloperIDE NameDownload InstructionsPrice
JetBrainsIntelliJ IDEA Ultimatehttps://www.jetbrains.com/idea/downloadPaid
JetBrainsIntelliJ IDEA Community Edition (recommended)https://www.jetbrains.com/idea/downloadFree
Eclipse FoundationEclipsehttps://www.eclipse.org/downloads/packages/installerFree
ApacheNetBeanshttps://netbeans.apache.org/downloadFree
MicrosoftVisual Studio Codehttps://code.visualstudio.com/downloadFree

Interesting Extras


Java is Functionless

A function is generally a reusable block of code that performs a specific task. In many programming languages, functions can exist independently of classes. However, in Java, all code must be contained within a class, and what other languages might call “functions” are referred to as “methods” in Java. Methods are similar to functions but are always associated with a class or object. Therefore, in Java, methods serve the role that standalone functions do in other languages.


What does Minecraft have to do with Java?

Minecraft was originally written in Java. That version is now branded as “Minecraft: Java Edition,” referencing the language it’s developed in. It has a thriving ecosystem of modders and modding tools. Developing your own mods is a great way to utilize your Java skills and have fun!


Arch Linux Integration

Arch has a built-in command line tool for managing Java versions called archlinux-java.