What Java is and why you need it

Java is a programming language and runtime environment — software that lets your computer run programs written in Java. Many applications, games, and web services depend on Java to work. If a program tells you that Java is missing or outdated, you need to install or update it on your machine.

Java comes in different versions. The most common one for everyday users is Java Runtime Environment (JRE), which runs Java programs. Developers who write Java code need Java Development Kit (JDK), which includes extra tools. This guide covers installing JRE, which is what most people need.

Java runs on Windows, macOS, and Linux. The installation steps differ slightly between operating systems, but the process is straightforward on all three.

Key Takeaways

  • Download Java from Oracle's official website (java.com or oracle.com) to avoid malware and fake versions.
  • Windows users run an installer file; macOS users typically use a .dmg installer; Linux users install through their package manager or download a .tar.gz file.
  • After installation, verify that Java works by opening a terminal or command prompt and typing java -version.
  • Java updates are released regularly, and you can check for updates through your system settings or by revisiting the download page.

Installing Java on Windows

Go to java.com or oracle.com/java/technologies/downloads in your web browser. Click the download button for Windows. The site detects your operating system automatically, so you should see a Windows option. Save the .exe installer file to your computer.

Open the file you downloaded. A setup wizard appears. Click Install and follow the on-screen prompts. The installer places Java in a default folder (usually C:\Program Files\Java) and adds it to your system. You may need to restart your computer for changes to take effect.

To confirm the installation worked, open Command Prompt (search for "cmd" in the Windows search bar) and type java -version, then press Enter. If Java is installed, you see the version number. If you see an error, Java did not install correctly or is not in your system path — try restarting your computer and running the command again.

Installing Java on macOS

Visit java.com or oracle.com/java/technologies/downloads and download the macOS version. The file is a .dmg installer. Open it by double-clicking, and a window appears showing the Java installer icon.

Double-click the installer icon to start the setup. Enter your password when prompted (macOS requires this to install system software). The installer places Java in /Library/Java/JavaVirtualMachines. Once installation finishes, close the window.

Open Terminal (search for "Terminal" in Spotlight or find it in Applications > Utilities) and type java -version, then press Enter. You should see the Java version number. If the command is not found, restart your computer and try again.

Installing Java on Linux

Linux distributions use package managers to install software. The exact command depends on your distribution. For Ubuntu or Debian-based systems, open a terminal and type sudo apt update, then sudo apt install default-jre. Enter your password when prompted.

For Red Hat, CentOS, or Fedora, use sudo yum install java-latest-openjdk instead. For Arch Linux, type sudo pacman -S jre-openjdk. These commands download and install Java automatically from your distribution's official repositories.

After installation completes, type java -version in the terminal to confirm. You should see the version number. If you prefer to download Java manually instead of using a package manager, visit oracle.com, download the Linux .tar.gz file, extract it to a folder like /opt/java, and add that folder to your system PATH — but using your package manager is simpler and keeps Java updated automatically.

Checking your Java installation and version

After installing, always verify that Java works. Open a terminal or command prompt on your system and type java -version. The output shows your Java version number and build information. If you see a version number, Java is installed and working.

If you see "java: command not found" or a similar error on Windows, macOS, or Linux, Java either did not install correctly or is not in your system's PATH. Restart your computer first — sometimes the PATH updates only after a restart. If the error persists, uninstall Java completely and download it again from the official source.

You can also check Java through your system settings. On Windows, go to Settings > Apps > Apps & Features and search for "Java" — you see any installed versions listed. On macOS, open System Preferences > General > Software Update to check for Java updates. On Linux, use your package manager to list installed packages: apt list --installed | grep java on Ubuntu/Debian.

Updating Java to the latest version

Java releases updates regularly to fix security issues and add features. On Windows, you can check for updates by going to Settings > Apps > Apps & Features, finding Java, and clicking it to see if an update is available. Alternatively, download the latest version from java.com and run the installer — it replaces your old version automatically.

On macOS, updates sometimes appear in System Preferences > General > Software Update. You can also download the latest .dmg installer from java.com and run it to update. On Linux, your package manager handles updates automatically if you installed Java through it — just run sudo apt upgrade (Ubuntu/Debian) or sudo yum upgrade (Red Hat/CentOS) periodically.

To see which version you currently have, type java -version in a terminal or command prompt. Compare the version number to the latest version listed on java.com. If yours is older, download and install the newer version using the steps above for your operating system.

Troubleshooting common installation problems

If a program says Java is missing but you installed it, the program may be looking for a specific Java version or location. Try restarting your computer — the PATH (the list of folders your system searches for programs) sometimes updates only after a restart. If that does not work, uninstall Java completely and reinstall it.

On Windows, if the installer fails or hangs, download the offline installer instead of the online one from oracle.com. The offline installer is larger but does not require an internet connection during setup. On macOS, if you see a security warning, right-click the .dmg file, select Open, and confirm that you trust it.

If you downloaded Java from a website other than java.com or oracle.com, delete it and download again from the official source. Fake Java installers exist and can install malware. Always use the official Oracle website. If Java still does not work after reinstalling, check whether your antivirus or firewall is blocking it — temporarily disable these and try again, then re-enable them.

Frequently Asked Questions

Do I need Java Development Kit (JDK) or just Java Runtime Environment (JRE)?

Most people need only JRE, which runs Java programs. JDK is for people who write Java code. If a program asks you to install Java, it almost certainly means JRE. Download from java.com for JRE or oracle.com for JDK.

Is Java safe to install?

Java from oracle.com and java.com is safe. Java from other websites may not be. Always download from the official Oracle website. Java has had security issues in the past, but Oracle releases updates regularly to fix them. Keep Java updated to stay secure.

Can I have multiple Java versions installed at the same time?

Yes, you can install multiple versions. Some older programs need older Java versions. On Windows and macOS, each version installs to a separate folder. On Linux, your package manager handles this. Most programs use whichever version is set as default, which you can change through system settings.

Why does my computer ask me to update Java so often?

Oracle releases Java updates frequently to patch security vulnerabilities. These updates are important — they close holes that malware could exploit. You can set Java to update automatically through your system settings, or check for updates manually every few months.

What if a website says I need to install Java to view it?

Most modern websites do not need Java. If a website insists you install Java to view it, that website is likely outdated or suspicious. Legitimate websites use other technologies like JavaScript (which is different from Java). Be cautious before installing anything a website requests.