FedoraRHEL Based

How To Install Java on Fedora 39

Install Java on Fedora 39

In this tutorial, we will show you how to install Java on Fedora 39. Java, developed by Sun Microsystems (now owned by Oracle Corporation), is a high-level, object-oriented programming language renowned for its “write once, run anywhere” philosophy. This means that Java applications can run on various platforms with minimal changes. Java is the bedrock for countless software applications, including web and mobile applications, big data processing, and more.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Java programming language on a Fedora 39.

Prerequisites

Before diving into the installation process, let’s ensure that you have everything you need:

  • A server running one of the following operating systems: Fedora 39.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • You’ll need an active internet connection to download Java and its dependencies.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Java on Fedora 39

Step 1. Before embarking on any software installation, it’s a wise practice to update your Fedora 39 system to ensure you have the latest packages and security updates. Open your terminal and enter the following command:

sudo dnf clean all
sudo dnf update

This command will update all your installed packages to their latest versions. Be patient, as this process may take some time, depending on your system’s speed and the number of updates available.

Step 2. Installing Java on Fedora 38.

Now, it’s time to install Java itself. We’ll focus on OpenJDK, which is open-source and widely supported:

sudo dnf install java-11-openjdk

This command installs OpenJDK 11, a long-term support (LTS) version, suitable for most applications.

If you need a more recent version, OpenJDK 16 is available:

sudo dnf install java-17-openjdk-devel

To ensure that the Java installation is successful, run the following command:

java -version

You should see information about the installed Java version. If you encounter any errors, revisit the installation steps and ensure you followed them correctly.

Step 3. Setting Environment Variables.

Environment variables are crucial for configuring Java on Fedora 39. You need to set the JAVA_HOME variable and add the bin directory to the PATH. This can be done by editing your .bashrc file:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.13.0.8-1
export PATH=$PATH:$JAVA_HOME/bin

This ensures that Java-related commands are available system-wide.

Step 4. Testing Java Installation.

Before we conclude, let’s verify that Java is working as expected. You can do this by running a simple Java program, such as the “Hello, World!” program. Create a file called HelloWorld.java with the following content:

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

Compile and run it:

javac HelloWorld.java
java HelloWorld
If you see “Hello, World!” printed on your terminal, congratulations! Your Java installation on Fedora 39 is in perfect shape.

Congratulations! You have successfully installed Java. Thanks for using this tutorial for installing Java programming language on your Fedora 39 system. For additional Apache or useful information, we recommend you check the official Java website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button