Released · improving
Programming language · Since 1995
Java is a statically typed, object-oriented language that runs on the JVM and powers enterprise backends, Android apps, and large-scale data systems.
Java is a general-purpose, object-oriented programming language first released by Sun Microsystems in 1995 and now developed by Oracle together with the OpenJDK community. Java source code is compiled into bytecode that runs on the Java Virtual Machine (JVM), so the same program runs on Windows, macOS, and Linux without being recompiled. Automatic memory management and a strict static type system catch many errors early and keep large codebases maintainable.
Java is especially strong in server-side software that has to run reliably for years: web services and APIs built with frameworks such as Spring, financial and transaction-processing systems, and data platforms like Apache Kafka, Hadoop, and Spark. It also has a long history in Android development. The JVM's just-in-time compiler and mature garbage collectors deliver solid performance for long-running workloads, and Maven Central hosts a vast collection of open-source libraries.
To get started, install a JDK, for example an OpenJDK build such as Eclipse Temurin, then run a single source file directly with the java command or experiment interactively in JShell. The Learn section on dev.java walks through the language step by step, and the Java SE API documentation is the reference you will return to most often. Once a project grows beyond a few files, add a build tool such as Maven or Gradle and an IDE. In production, teams usually standardize on a long-term support (LTS) release.
Programs compile to platform-independent bytecode that runs on any JVM, so the same build works across operating systems and CPU architectures.
The garbage collector reclaims objects that are no longer used, ruling out a whole class of memory-freeing bugs, while the JIT compiler optimizes frequently executed code at run time.
Classes, interfaces, and generics catch type errors at compile time, and newer features such as lambdas, records, and pattern matching make code more concise.
The standard library covers collections, concurrency, I/O, networking, and much more, and Maven Central adds a wide range of open-source libraries.
Download and install an OpenJDK build such as Eclipse Temurin from adoptium.net. You can also use a package manager: winget on Windows, Homebrew on macOS, or your distribution's package manager or SDKMAN! on Linux. Unless you have a specific need, choose an LTS release.
Open a new terminal and check that both the runtime (java) and the compiler (javac) print their versions. If the command is not found, add the JDK's bin directory to PATH and set JAVA_HOME to the JDK folder.
java -version && javac -versionSave the example below as Hello.java and run it directly with the java command; the JDK compiles and runs the source file in a single step.
java Hello.javaThe Hello class defines a main method, the entry point the JVM calls when the program starts, and System.out.println prints a line to the console. The file name must match the name of the public class. Recent JDKs can run a single source file directly with java Hello.java, compiling it in memory without a separate javac step; larger projects are compiled with javac or a build tool before the classes are run.
Hello.java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
java Hello.javaSix chapters that take you from installation to the core ideas of Java.
Ask questions, share experience and trade opinions about Java.
No discussions yet. Start the first one.
0 comments
Sign in · Sign in to leave a comment.
Be the first to comment.