What Is Java?
Author: Domeny.ForSale editorial team Published
In brief: Java is a programming language and an associated platform for building and running applications. It is used in business systems, web services and Android applications, among other things. Java is not the same as JavaScript, and you usually do not need to install it for ordinary web browsing.
What is Java, and how does a program written in it work?
A programming language lets you write instructions that a computer executes. In Java, a programmer describes, for example, how to calculate the price of an order, save customer data or check product availability. Java is a general-purpose language: it is not limited to a single kind of application.
Java is statically typed, meaning that data types are checked during compilation—the process of converting code into a form intended for execution. This helps detect some errors before the program runs. Classes and objects also play a fundamental role in Java: a class describes the structure of data and the available operations, while an object is a specific instance of that class, such as a particular order.
Typical Java code is compiled into bytecode, which consists of instructions for the JVM. The JVM, or Java Virtual Machine, executes these instructions on a given operating system. This allows the same program to run on different systems, provided they have a compatible environment and the necessary dependencies. However, this does not guarantee complete portability: an application may use libraries or features available only on a particular system.
Java automatically reclaims memory occupied by objects that the program no longer needs. This mechanism is called garbage collection. It simplifies memory management, but it does not remove the programmer’s responsibility to maintain performance or close files and connections.
What is Java used for?
Java is particularly well suited to applications that process data, serve many users and require long-term maintenance. Its ecosystem includes libraries and frameworks—ready-made tools and structures that make software development easier. One example is Spring, which is used to build server-side applications.
Typical uses include:
- Web application backends—the part that runs on the server and is responsible for tasks such as login, orders and communication with a database.
- Business systems—handling payments, billing, inventory or business processes.
- Android applications—Java remains a supported language on this platform, although Google recommends starting new applications with Kotlin. Android uses its own runtime environment rather than the standard JVM found on computers.
- Desktop programs and tools—applications with graphical interfaces and programs that perform tasks automatically.
For example, an online store might have a browser interface written in JavaScript and a backend written in Java. Clicking “Buy” sends a request to the server, where a Java program checks stock levels and saves the order. The store’s user does not need to install Java on their computer.
Java and JavaScript: similar names, different languages
Java and JavaScript are separate languages, not two versions of the same tool. They differ in how they work, their type systems and their ecosystems. Knowing one does not automatically mean knowing the other.
JavaScript is normally executed by browsers and is responsible for features such as interactive elements on websites. It can also run on a server, for example in the Node.js environment. Java usually runs as a server-side, desktop or mobile application; modern browsers no longer run the old Java applets through a plugin.
If you want to build website interfaces, HTML, CSS and JavaScript are natural starting points. If you are interested in server-side services or developing existing systems written in Java, learning Java is the more direct choice.
Do you need to install Java? JDK, JRE and security
Java is not generally required to use a computer or browse the internet. You install it when a specific program needs it, or when you want to build applications yourself. Some programs include their own runtime environment, so a separate installation is not necessary.
When downloading Java, you may encounter three abbreviations:
- JVM—the virtual machine that executes bytecode.
- JRE—the runtime environment, which includes the JVM and the libraries applications need; not every provider offers it as a separate package today.
- JDK—the development kit, which includes a runtime environment, a compiler and other tools.
Choose a JDK for learning. To run an existing program, check its official documentation for the required Java version and installation instructions. A newer version will not always replace an older one without problems.
Download the JDK from your chosen provider’s official website and install security updates. Licence terms and support periods depend on the distribution and version, so confirm them with the provider before business use. The name “Java” alone does not imply a single, identical licence for all packages.
How do you run your first Java program?
After installing the JDK, check the commands java -version and javac -version in a terminal. The first shows the available runtime environment; the second shows the compiler. If the system does not recognise the commands, check the configuration of the PATH variable, which specifies where to look for programs.
Save the following code in a file named Start.java:
public class Start {
public static void main(String[] args) {
System.out.println("Hello, Java!");
}
}
Then, in the folder containing the file, run:
javac Start.java
java Start
The first command creates the Start.class file, and the second runs the program. Here, the source file’s name must match the name of the public class, Start. The main method is the starting point for execution, and System.out.println prints text.
As a next step, change the message, add two numeric variables and display their sum. This will take you beyond installation and let you explore how Java stores data and performs operations.
