How To Install Java on Fedora 43

Java remains one of the most widely-used programming languages worldwide, powering everything from Android applications to enterprise-level systems. Whether you’re developing cutting-edge IoT devices, building robust web applications, or maintaining legacy enterprise software, having Java properly configured on your Fedora 43 system is essential. This comprehensive guide walks you through multiple installation methods, version management techniques, and troubleshooting strategies to ensure a smooth Java setup on your Fedora workstation or server.
Fedora 43 brings excellent support for the latest Java versions, including the newly released Java 25 LTS and the well-established Java 21 LTS. Understanding the differences between Java Runtime Environment (JRE) and Java Development Kit (JDK) is crucial before beginning installation. The JRE provides the necessary components to run Java applications, while the JDK includes development tools like the Java compiler (javac), debugger, and additional utilities required for software development.
Understanding Java Versions and Implementations
Java Implementations Available
When installing Java on Fedora 43, you’ll encounter two primary implementations. OpenJDK represents the open-source version of the Java Platform, Standard Edition, and serves as the preferred choice for Fedora users due to its seamless integration with the operating system’s package management system. Oracle Java SE, the proprietary implementation from Oracle Corporation, offers commercial support options but requires manual installation procedures.
OpenJDK delivers excellent performance and full compatibility with Java specifications while maintaining complete freedom from licensing restrictions. The Fedora Project actively maintains and tests OpenJDK packages, ensuring optimal performance on Red Hat-based distributions. Oracle Java SE may be necessary for specific enterprise applications that require certified Oracle JDK builds, though most modern applications run flawlessly on OpenJDK.
Available Java Versions in Fedora 43
Fedora 43 repositories provide access to multiple Java versions, allowing developers to choose the most appropriate release for their projects. Java 25 LTS, released in September 2025, represents the latest long-term support version with extended maintenance and security updates. Java 21 LTS continues to receive support and remains an excellent choice for production environments requiring proven stability.
The java-latest-openjdk package provides access to the most recent Java release, though non-LTS versions receive shorter support cycles. Long-term support versions receive security patches and critical bug fixes for several years, making them ideal for production deployments. Non-LTS releases offer cutting-edge features but transition to end-of-life status more rapidly. Choose LTS versions when stability matters most, or experiment with latest releases for testing new language features.
Prerequisites and System Preparation
Before installing Java, verify your system meets the basic requirements. You need Fedora 43 Workstation or Server edition with active internet connectivity. Administrative privileges through sudo access are essential for package installation and system-wide configuration. Access to the terminal or command-line interface provides the primary method for executing installation commands.
Check if Java is already installed by opening a terminal and executing:
java --version
If Java is not installed, the system returns a “command not found” error. Update your system packages to ensure compatibility with the latest Java releases:
sudo dnf update
The DNF package manager, Fedora’s default software management tool, handles dependency resolution automatically. Ensure you have at least 500 MB of free disk space for a complete JDK installation, though actual requirements vary depending on the selected version and additional development tools.
Method 1: Installing OpenJDK from Fedora Repository
Listing Available OpenJDK Versions
The Fedora repository contains multiple OpenJDK versions, each packaged for x86_64 architecture. Query available packages using:
dnf search openjdk
This command displays all OpenJDK packages, including runtime-only and development packages. The output includes entries like java-21-openjdk, java-25-openjdk, and java-latest-openjdk. Package names follow a consistent format: java-[version]-openjdk for runtime packages and java-[version]-openjdk-devel for development packages.
Understanding the naming convention helps identify the correct package quickly. The x86_64 suffix indicates compatibility with 64-bit Intel/AMD processors. Packages without the -devel suffix provide only the runtime environment, suitable for running Java applications but insufficient for development work.
Installing OpenJDK JRE (Runtime Only)
When your primary goal involves running Java applications rather than developing them, the JRE package provides everything needed. Install Java 21 runtime with:
sudo dnf install java-21-openjdk.x86_64
Alternatively, install Java 25 for the newest LTS release:
sudo dnf install java-25-openjdk.x86_64
Or choose the latest available version:
sudo dnf install java-latest-openjdk.x86_64
DNF automatically resolves dependencies and downloads required packages. When prompted, type ‘y’ and press Enter to confirm installation. The process typically takes 2-5 minutes depending on your internet connection speed. Installation places Java files in the /usr/lib/jvm/ directory, where multiple versions can coexist without conflicts.
Installing OpenJDK JDK (Development Kit)
Developers need the full JDK package containing the Java compiler, debugging tools, and development utilities. Install the Java 21 development kit:
sudo dnf install java-21-openjdk-devel.x86_64
For Java 25 development:
sudo dnf install java-25-openjdk-devel.x86_64
Or install the latest development tools:
sudo dnf install java-latest-openjdk-devel.x86_64
The -devel package includes javac (the Java compiler), jar (archive tool), jdb (debugger), javadoc (documentation generator), and numerous other utilities essential for software development. Package sizes range from 150-250 MB, requiring slightly longer installation times than runtime-only packages. The devel package automatically includes the corresponding JRE, eliminating the need for separate runtime installation.
Verifying OpenJDK Installation
Confirm successful installation by checking the Java version:
java --version
The output displays version information, build date, and JVM details:
openjdk 21.0.5 2024-10-15 LTS
OpenJDK Runtime Environment (Red Hat-21.0.5.0.11-1.fc43)
OpenJDK 64-Bit Server VM (Red Hat-21.0.5.0.11-1.fc43, mixed mode, sharing)
Verify the Java compiler installation (for JDK packages):
javac -version
Expected output shows the compiler version matching your Java installation. Check executable locations:
which java
which javac
These commands return paths like /usr/bin/java and /usr/bin/javac, confirming proper PATH configuration. Successful verification ensures Java is ready for application development or deployment.
Method 2: Installing Oracle Java SE (Manual Installation)
Downloading Oracle JDK
Oracle Java SE requires manual download from Oracle’s official website. Navigate to the Oracle Java SE Downloads page using your web browser. Select the appropriate version (Java SE 21, 25, or latest release) based on your requirements. Click the download link for Linux x64 Compressed Archive (tar.gz format).
Accept Oracle’s license agreement to proceed with the download. Choose the tar.gz package rather than RPM packages, as Oracle RPMs conflict with Fedora’s OpenJDK package management structure. The compressed archive downloads to your ~/Downloads directory by default. Verify the downloaded file’s integrity by checking its size matches Oracle’s specifications.
Installing Oracle JDK from tar.gz Archive
Create a dedicated directory for Oracle Java installation:
sudo mkdir -p /usr/local/java
Navigate to your Downloads folder:
cd ~/Downloads
Copy the downloaded archive to the Java directory (adjust filename to match your downloaded version):
sudo cp -r jdk-21_linux-x64_bin.tar.gz /usr/local/java
Change to the Java installation directory:
cd /usr/local/java
Extract the compressed archive:
sudo tar xvzf jdk-21_linux-x64_bin.tar.gz
The extraction process creates a directory named jdk-21 (or similar, depending on your version) containing all Java binaries and libraries. The verbose flag (v) displays extraction progress, while the z flag handles gzip compression automatically. Extraction completes within seconds to a minute depending on system performance.
Configuring Environment Variables
System-wide Java configuration requires modifying the profile file. Open the profile configuration:
sudo nano /etc/profile
Scroll to the file’s end and add these lines (adjust path for your Java version):
JAVA_HOME=/usr/local/java/jdk-21
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
Save changes by pressing Ctrl+O, then Enter, followed by Ctrl+X to exit nano. The JAVA_HOME variable informs applications of Java’s installation location, while the PATH modification enables executing Java commands from any directory.
Activate the new configuration:
source /etc/profile
Alternatively, log out and log back in for changes to take effect system-wide. Verify the configuration by checking Java version:
java -version
The output should display Oracle Java information rather than OpenJDK details.
Managing Multiple Java Versions
Understanding the Alternatives System
Fedora’s alternatives system manages multiple versions of programs that serve identical functions. This mechanism creates and maintains symbolic links in /usr/bin/, pointing to specific versions in /usr/lib/jvm/. The alternatives command provides a clean interface for switching between Java versions without manually editing system files.
Each Java installation registers with alternatives during package installation, receiving a priority value determining default selection. Higher priority values automatically become the system default unless manually overridden. This system prevents conflicts when multiple Java Development Kits coexist on your workstation.
Listing Installed Java Versions
Display all registered Java installations:
sudo alternatives --config java
The output presents a menu showing available versions:
There are 3 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 java-21-openjdk.x86_64 (/usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc43.x86_64/bin/java)
2 java-25-openjdk.x86_64 (/usr/lib/jvm/java-25-openjdk-25.0.1.0.9-1.fc43.x86_64/bin/java)
3 java-latest-openjdk.x86_64 (/usr/lib/jvm/java-24-openjdk-24.0.2.0.1-1.fc43.x86_64/bin/java)
Enter to keep the current selection[+], or type selection number:
The asterisk (*) and plus sign (+) indicate the currently active version. Each entry includes the full path to the Java executable, helping identify exact installation locations.
Switching Between Java Versions
To change the active Java version, run the alternatives configuration command and enter your preferred selection number. For example, typing ‘2’ selects Java 25 as the system default. The change takes effect immediately without requiring system restart or logout.
Switch the Java compiler separately:
sudo alternatives --config javac
Maintaining consistent versions between java and javac prevents compilation errors. Always verify version consistency after switching:
java --version
javac -version
Application-specific requirements may necessitate different Java versions. Some legacy applications require Java 8 or 11, while modern frameworks leverage features from Java 17 or later. Keep documentation noting which applications require specific Java versions.
Setting a Default Java Version Permanently
Configure a persistent default Java version using the set command:
sudo alternatives --set java /usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc43.x86_64/bin/java
This command bypasses the interactive menu, directly establishing the specified version as default. The setting persists across system reboots and user sessions. Repeat for the Java compiler:
sudo alternatives --set javac /usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc43.x86_64/bin/javac
Installing Java Development Tools and Ecosystem
Beyond the core JDK, comprehensive Java development requires build automation tools and dependency managers. Fedora provides the “Java Development” package group containing essential development utilities:
sudo dnf group install "Java Development"
This group installation includes Apache Maven, a powerful project management and build automation tool. Apache Ant, the classic Java build tool, provides XML-based build configuration. Additional libraries support various development scenarios from enterprise applications to Android development.
Verify Maven installation:
mvn --version
Check Ant availability:
ant -version
Modern Java development typically relies on Integrated Development Environments (IDEs) offering code completion, debugging, and project management features. IntelliJ IDEA Community Edition provides excellent Java support at no cost. Eclipse IDE remains popular in enterprise environments, while Visual Studio Code with Java extensions offers lightweight development capabilities.
Testing Your Java Installation
Creating a Simple Test Program
Validate your Java installation by creating and running a basic program. Open your preferred text editor (nano, vim, or gedit):
nano HelloWorld.java
Enter this simple Java program:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Fedora 43!");
}
}
Save the file ensuring the filename matches the class name exactly—Java requires this correspondence. The .java extension identifies source code files requiring compilation before execution.
Compiling and Running Java Code
Compile the source code into Java bytecode:
javac HelloWorld.java
Successful compilation produces no output but creates HelloWorld.class containing executable bytecode. Compilation errors appear with line numbers and descriptions helping identify syntax issues. Run the compiled program:
java HelloWorld
The output displays:
Hello, Fedora 43!
Java 11 and later versions support single-file execution without explicit compilation:
java HelloWorld.java
This convenience feature suits quick testing and scripting scenarios, though production applications still require formal compilation and packaging.
Troubleshooting Common Installation Issues
Java Command Not Found
When the system cannot locate the java command, check your PATH configuration:
echo $PATH
Verify the output includes Java’s bin directory. If missing, source the profile file:
source /etc/profile
For persistent problems, edit your shell configuration file (~/.bashrc for Bash users) adding:
export PATH=$PATH:/usr/lib/jvm/java-21-openjdk-21.0.5.0.11-1.fc43.x86_64/bin
Reload the configuration:
source ~/.bashrc
Version Conflicts
Multiple Java installations sometimes cause unexpected behavior. Use alternatives to explicitly select the desired version:
sudo alternatives --config java
Check JAVA_HOME consistency:
echo $JAVA_HOME
Ensure JAVA_HOME points to your intended Java installation. Application-specific Java requirements may override system defaults through their own configuration files.
Permission Denied Errors
Installation failures due to insufficient privileges require sudo access. Verify your user account belongs to the wheel group (Fedora’s administrative group):
groups
File ownership issues occasionally prevent proper execution. Check Java directory permissions:
ls -la /usr/lib/jvm/
Fedora’s SELinux security framework may restrict Java operations. Check SELinux status:
getenforce
If SELinux blocks Java, consult SELinux logs in /var/log/audit/audit.log for specific denials requiring policy adjustments.
Package Not Found Errors
Repository synchronization issues cause package availability problems. Update DNF’s package cache:
sudo dnf makecache
Verify repository configuration:
dnf repolist
Ensure the fedora and updates repositories are enabled. Network connectivity problems prevent package downloads—verify internet access and DNS resolution.
Best Practices and Recommendations
Selecting appropriate Java versions significantly impacts application stability and security. LTS versions (Java 21 or 25) provide extended support cycles ideal for production environments. Non-LTS releases suit experimentation and feature testing but transition to end-of-life more quickly.
OpenJDK from Fedora repositories integrates seamlessly with system package management, receiving automatic security updates through regular system updates. Oracle JDK necessitates manual update procedures but may be required for specific enterprise software certifications. Regular updates protect against security vulnerabilities:
sudo dnf update
Document Java version requirements for each application in your environment. Maintain development environments matching production configurations to minimize deployment surprises. The alternatives system provides clean version management without manual symbolic link manipulation.
Configure JAVA_HOME consistently across all development tools ensuring Maven, Gradle, and IDEs reference identical Java installations. Test applications thoroughly after Java updates, particularly when upgrading major versions. Consider containerization technologies like Docker for project-specific Java version isolation.
Security updates deserve prompt application as Java vulnerabilities enable remote code execution attacks. Monitor Java security advisories through the Fedora security announcement mailing list. Performance tuning opportunities exist through JVM options, though default configurations suit most scenarios.
Uninstalling Java from Fedora 43
Removing Java installations requires different procedures depending on installation method. List installed OpenJDK packages:
dnf list installed | grep java
Remove a specific OpenJDK version:
sudo dnf remove java-21-openjdk
Completely remove all Java packages:
sudo dnf remove java-*-openjdk*
Exercise caution with wildcard removal commands as they affect all matching packages. For Oracle JDK installed manually, delete the installation directory:
sudo rm -rf /usr/local/java/jdk-21
Edit /etc/profile removing JAVA_HOME and PATH modifications related to Oracle Java. Update alternatives if necessary:
sudo alternatives --remove java /usr/local/java/jdk-21/bin/java
Verify complete removal:
java --version
The command should return “command not found” after successful uninstallation.
Congratulations! You have successfully installed Java. Thanks for using this tutorial for installing the Java programming language on your Fedora 43 Linux system. For additional or useful information, we recommend you check the official Java website.