Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Install Java on Linux Mint: Choose and Set Up a JDK

· 5 min read · Home Tech

In this article
  1. Which Java package should you install?
  2. Install OpenJDK from Terminal
  3. Install using Software Manager
  4. Verify Java and choose a version
  5. Set JAVA_HOME when a tool needs it
  6. Common installation problems
  7. Frequently Asked Questions

To install Java on Linux Mint, open Terminal and install the OpenJDK package with APT: run sudo apt update, then sudo apt install default-jdk. Confirm it works with java -version and javac -version; if you only need to run Java programs, install default-jre instead.

Which Java package should you install?

Java is both a programming language and a runtime environment. Linux Mint’s software repositories provide OpenJDK, the open-source Java implementation. For most users, it is the simplest choice and works for common applications and development tools.

  • JRE (Java Runtime Environment): supplies the components needed to run many Java applications. Install it with sudo apt install default-jre.
  • JDK (Java Development Kit): includes the runtime plus tools such as the Java compiler, javac. Choose this if you will write, compile, or build Java software.
  • Default package: default-jre and default-jdk select the versions designated as the default by your Mint release’s repositories. That version can vary between releases.

Installing the JDK is also a convenient option if you are unsure which package you need: it includes the tools required to run Java programs. A separate Java installation from Oracle is not usually necessary for ordinary desktop use.

Install OpenJDK from Terminal

Linux Mint is based on Ubuntu, and APT installs packages from the repositories configured for your system. Use the following steps:

  1. Open Terminal from the Mint menu.
  2. Refresh the package information: sudo apt update. Enter your account password if prompted; the characters will not appear as you type.
  3. Install the JDK: sudo apt install default-jdk. Read the package summary and confirm when APT asks whether to continue.
  4. Check the runtime and compiler: java -version and javac -version.

To install only the runtime, substitute default-jre in the installation command. APT may install additional dependencies, which is normal. If it says the package is already at the newest version, it is installed or the repository’s current package is already present.

Install using Software Manager

If you prefer a graphical interface, open Software Manager from the Mint menu, search for openjdk, and select an appropriate Java development kit or runtime package offered for your system. Package names and available versions can differ by Mint release, so check the description before installing. Authenticate when requested.

Software Manager uses the system’s package sources, much like APT. It is not a different kind of Java installation. For the clearest control over which package you install—and for troubleshooting commands—Terminal is often easier to follow.

Verify Java and choose a version

After installation, java -version reports the active Java runtime. If you installed the JDK, javac -version checks the compiler. A successful response includes a version number; exact wording varies by OpenJDK release.

Some projects require a particular Java release. Check the project’s documentation before choosing a version: “latest” is not always the same as “compatible.” To see Java-related packages available from your configured repositories, try apt search openjdk. You can check which Java executable is selected with which java.

If more than one Java version is installed, Mint’s underlying Debian/Ubuntu tools may let you select the default. Run sudo update-alternatives --config java to view and choose among registered runtime alternatives. If you compile code, check the compiler separately with sudo update-alternatives --config javac. These commands only show choices when multiple alternatives are registered.

Set JAVA_HOME when a tool needs it

Many Java programs find Java without any extra configuration. Some development environments, build tools, or older applications specifically ask for JAVA_HOME. This variable should point to a JDK directory, not to the java executable itself.

To locate the active Java installation, run readlink -f $(which java). The result commonly ends in /bin/java; the Java home directory is the path before that final /bin/java. For a quick, session-only setting, replace the example path with the one appropriate to your system:

export JAVA_HOME=/path/to/your/jdk
export PATH="$JAVA_HOME/bin:$PATH"

These commands apply to the current Terminal session. For a permanent setting, put the correct path in your shell’s startup configuration, such as ~/.bashrc for Bash, then open a new Terminal or reload that file. Do not copy a version-specific directory from another computer without checking that it exists on yours.

Common installation problems

  • “Unable to locate package”: run sudo apt update and check that your Mint software sources are enabled and reachable. Confirm the package spelling and your Mint release’s supported repositories.
  • java works but javac is missing: you likely installed only a runtime. Install default-jdk if you need to compile Java code.
  • The wrong version is active: inspect java -version and use update-alternatives if multiple registered versions are installed. Also check whether an application requires a specific release.
  • An application still cannot find Java: read its error message and documentation. It may require a JDK, a particular version, or an explicitly configured JAVA_HOME.

Be cautious about downloading installers from unfamiliar sites or adding third-party repositories just to get a newer version. Those choices affect system updates and trust; use a project’s documented, reputable source only when the Mint repositories do not meet its requirements.

Frequently Asked Questions

Is Java already installed on Linux Mint?
Not necessarily. Check with java -version. If the command is not found, install a runtime or JDK through APT.

Should I install the JDK or JRE?
Choose the JRE to run Java applications only. Choose the JDK to develop or compile Java programs; it also provides the runtime.

Is OpenJDK the same as Oracle Java?
They are different implementations of Java. OpenJDK is available through Mint’s normal package sources and is suitable for many users. Use Oracle’s distribution only if a specific requirement calls for it, and follow its licensing and installation terms.

How do I uninstall Java?
Use APT to remove the package you installed, for example sudo apt remove default-jdk. Review APT’s proposed changes before confirming, since other packages may depend on Java. Removing a package may leave configuration files; sudo apt autoremove can remove unused dependencies, but review its list first.

Do I need to restart Linux Mint after installing Java?
Usually not. Close and reopen a Terminal or application if it needs to refresh its environment; a full system restart is generally unnecessary.