Java
In short
Java is a statically typed, object-oriented programming language that compiles to bytecode for the Java Virtual Machine, so programs run on many platforms.
What is Java?
Java is a general-purpose, object-oriented programming language first released by Sun Microsystems in 1995 and now developed by Oracle together with the open-source OpenJDK community. Its motto, "write once, run anywhere," describes the core idea: Java source code is compiled into bytecode, which runs on any device that has a Java Virtual Machine (JVM). A new version ships every six months, with a long-term support (LTS) release every two years.
Java is statically typed, so every variable's type is known at compile time and many mistakes are caught before the program runs. Since Java 10, the var keyword lets the compiler infer the type of a local variable, but that type is still fixed. Memory is managed by a garbage collector, and there is no manual freeing of memory or pointer arithmetic. While a program runs, the JVM's just-in-time (JIT) compiler turns frequently used bytecode into fast native machine code.
Java is widely used for enterprise backend systems, banking and payment software, big data tools, and Android apps. The JVM works like a universal adapter: you compile the program once, and each operating system's JVM takes care of running it on that machine's hardware. Other languages, such as Kotlin and Scala, also compile to JVM bytecode and can use Java libraries.
Java and JavaScript are completely separate languages, despite the similar names. JavaScript was named in 1995 largely as a marketing move while Java was popular, and developers like to say the two are as related as car and carpet. Java is statically typed, compiled to bytecode, and runs on the JVM, while JavaScript is dynamically typed and runs mainly in web browsers and on servers through runtimes like Node.js.
Key takeaways
- Java is not related to JavaScript; the similar name is a historical marketing decision.
- Code compiles to bytecode that runs on the Java Virtual Machine (JVM).
- It is statically typed and strongly object-oriented.
- Memory is managed automatically by a garbage collector.
- It is widely used for enterprise backends, Android apps, and large-scale systems.
Example
// Every Java program starts from a main method inside a class
public class Hello {
public static void main(String[] args) {
String name = "World";
System.out.println("Hello, " + name + "!");
}
}Readers ask
Is Java the same as JavaScript?
No. They are separate languages with different designs, runtimes, and uses. Java is statically typed and runs on the JVM, while JavaScript is dynamically typed and runs mainly in browsers and in server runtimes like Node.js.
What is the difference between the JDK, JRE, and JVM?
The JVM is the virtual machine that runs Java bytecode. The JRE (Java Runtime Environment) bundles the JVM with the standard libraries needed to run programs, and the JDK (Java Development Kit) adds the compiler and other tools needed to write them.
Is Java still widely used?
Yes. Java remains one of the most widely used languages for backend and enterprise software, and it keeps gaining new features, such as records, pattern matching, and virtual threads, through regular releases.
See also
- Python vs JavaPython is a concise, dynamically typed language popular for data, AI and scripting, while Java is a statically typed JVM language for enterprise and Android.
- Java vs JavaScriptJava is a statically typed language compiled to bytecode for the JVM; JavaScript is a dynamically typed language that runs in browsers and on Node.js.
- Java vs KotlinJava is the original JVM language, stable and everywhere; Kotlin is a newer, more concise JVM language with built-in null safety, preferred for Android.
- C# vs JavaC# and Java are similar statically typed, garbage-collected languages; C# runs on Microsoft's .NET, Java on the JVM, and each has its own ecosystem.
- JavaScriptWeb Development, p. 29JavaScript is the programming language that runs in web browsers to make pages interactive, and it also runs on servers through runtimes like Node.js.
- OOPProgramming Fundamentals, p. 46OOP, or object-oriented programming, is a way of structuring code around objects that bundle related data together with the functions that act on that data.
- Garbage CollectionProgramming Fundamentals, p. 28Garbage collection is automatic memory management in which the language runtime finds data a program can no longer use and frees that memory for reuse.
- CompilerProgramming Fundamentals, p. 13A compiler is a program that translates source code written in a programming language into a lower-level form, such as machine code, that a computer can run.
- KotlinProgramming Languages, p. 18Kotlin is a concise, statically typed language that runs on the JVM, works seamlessly with Java, and is widely used for Android and server-side development.
- ClassProgramming Fundamentals, p. 10A class is a blueprint in object-oriented programming that defines the data and behavior shared by a group of objects, which are created from it as instances.
- Spring BootBackend & APIs, p. 49Spring Boot is a Java framework for quickly building production-ready services on top of Spring, with auto-configuration and an embedded web server.
- JVMProgramming Languages, p. 17The JVM runs Java bytecode, so the same compiled program works on any operating system; Kotlin, Scala and Clojure compile to that bytecode too.
Free · once a week
Software and AI, explained once a week
The week's software and AI news with every term explained, plus a term to learn and a quick quiz. A two-minute read.
See this week's issueAbout this page
Spotted a mistake or something missing on this page?Suggest an edit
How pages are made