Set JAVA_HOME :

echo "JAVA_HOME=/etc/alternatives/jre" >> ~/.profile
source ~/.profile
echo $JAVA_HOME
Answer from Karima Rafes on Stack Overflow
🌐
Medium
computingpost.medium.com › set-java-home-on-centos-rhel-fedora-afa5842e46ef
Set JAVA_HOME on CentOS / RHEL / Fedora | by ComputingPost | Medium
October 21, 2022 - I’ve seen many questions on how to set JAVA_HOME on CentOS / Fedora / RHEL Linux distributions. JAVA_HOME is used to set the path of Java installation on a Linux or Windows system. JAVA_HOME is just a convention and it is usually used by Java EE and Tomcat servers and build tools such as Gradle, Ant and Maven to find where Java is installed.
Discussions

environment variables - How to set Oracle Java's JAVA_HOME in Fedora 19 - Unix & Linux Stack Exchange
I just installed Fedora 19 and managed to get FedoraUtils installed. So I chose java oracle. after installation I could see in the FedoraUtils list that oracle java (installed) but I can't see the More on unix.stackexchange.com
🌐 unix.stackexchange.com
How do I fix java environment variables in fedora? Thanks in advance.
https://fedoramagazine.org/java-development-on-fedora-linux/ More on reddit.com
🌐 r/Fedora
13
15
September 23, 2021
linux - Fedora OpenJDK Set JAVA_HOME - Stack Overflow
I am using Fedora(actually Pidora since I am trying to set up hadoop on a cluster of raspberrypi). I installed oopenjdk on all of the nodes using ansible. However, when I tried to set up the JAVA_HOME environment variable, I got really confused looking at the folder of /usr/lib/jvm: More on stackoverflow.com
🌐 stackoverflow.com
September 10, 2017
fedora - How to install jdk1.8 and set its path on fedora28? - Unix & Linux Stack Exchange
To have all the binaries in /home/myuser/programs/jdk1.8.0_161/bin available use · export JAVA_HOME=/home/myuser/programs/jdk1.8.0_161 export PATH=$JAVA_HOME/bin:$PATH · This sets the environment variable JAVA_HOME to the directory where you extracted all the files and puts all binaries in ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
April 17, 2018
🌐
Reintech
reintech.io › blog › installing-java-setting-java-home-fedora-38
Installing Java and Setting JAVA_HOME on Fedora 38
January 31, 2024 - Many Java-based tools—Maven, Gradle, Tomcat, IntelliJ IDEA—use this environment variable to locate the Java installation directory. Without it properly set, you'll encounter build failures and runtime errors that can be frustrating to debug. Think of JAVA_HOME as a contract between your system and Java applications: "Here's where Java lives, and this is the version I want you to use." Fedora ships with OpenJDK in its default repositories, which means you get security updates automatically through your system's package manager.
🌐
ComputingForGeeks
computingforgeeks.com › home › dev › set java_home on centos / rhel / fedora
Set JAVA_HOME on CentOS / RHEL / Fedora | ComputingForGeeks
November 14, 2023 - I’ve seen many questions on how to set JAVA_HOME on CentOS / Fedora / RHEL Linux distributions. JAVA_HOME is used to set the path of Java installation on a Linux or Windows system.
🌐
Alejandro
alejandro.bio › node › 83
How to install Java JDK and set JAVA_HOME in Fedora | Alejandro Bernal Collazos
2. In order to set the JAVA_HOME please execute this command ( normally, java JDK will be placed into this path : /usr/lib/jvm/java ) [user@machine ~]# export JAVA_HOME=/usr/lib/jvm/java · fedora · linux · java · About me · Profession · Experience · Formal Education ·
🌐
YouTube
youtube.com › amit kumar
Java development - Set up JAVA_HOME in fedora or ubuntu linux - YouTube
This demo for setting up JAVA_HOME system variable on Fedora-26 linux, exactly the same applies to Ubuntu linux as well.
Published   August 6, 2017
Views   1K
Find elsewhere
🌐
Reddit
reddit.com › r/fedora › how do i fix java environment variables in fedora? thanks in advance.
r/Fedora on Reddit: How do I fix java environment variables in fedora? Thanks in advance.
September 23, 2021 - When I had this, I just went ahead and ran a java program anyways and after that it automatically filled in my system jdk. ... vim /etc/profile . Prepend sudo if logged in as not-privileged user, ie. sudo vim. Press 'i' to get in insert mode ... logout and login again, reboot, or use source /etc/profile to apply changes immediately in your current shell ... An unofficial general interest community for the Fedora Project, Fedora Linux, and its associated software. ... Setting up Fedora 32 to use the latest Java version in development environments.
🌐
Nandor's
nandorx.wordpress.com › 2016 › 02 › 04 › set-java_home-and-path-on-linux
Set JAVA_HOME and PATH on Fedora – Nandor's
June 6, 2016 - For current user: vi ~/.bash_profile type it into the file, and replace jdk version: export JAVA_HOME=/usr/java/jdk1.8.0_71/ export PATH=$PATH:/usr/java/jdk1.8.0_71/bin/ In the terminal type: source ~/.bash_profile To verify the variables: echo ...
🌐
LinuxCapable
linuxcapable.com › home › fedora › how to set java environment path in fedora 44
How to Set Java Environment Path in Fedora 44 - LinuxCapable
May 15, 2026 - Fedora 44 and Fedora 43 differ ... you want the variable to follow the active Java version automatically. Install a JDK package before setting JAVA_HOME....
🌐
LYRASIS Wiki
wiki.lyrasis.org › display › FEDORA38 › Setting+JAVA_HOME+in+Windows
Setting JAVA_HOME in Windows - Fedora 3.8 Documentation - LYRASIS Wiki
Enter the variable name as JAVA_HOME. Enter the variable value as the installation path for the Java Development Kit. Click 'OK'. Click 'Apply Changes'. If you are running the Fedora Repository as a WAR rather than the Standalone, you may need to restart your application server.
🌐
Java67
java67.com › 2016 › 06 › how-to-set-javahome-and-path-in-linux.html
How to set JAVA_HOME and PATH in Linux? Example | Java67
Java developers like me always set mandatory environment variables like JAVA_HOME, PATH, and CLASSPATH on the login scripts executed by the shell when you log in to Linux like bash_profile.sh, but you can also set JAVA_HOME into /etc/profile for all users. I'll show you steps on how to find the location of Java and how to set up the JAVA_HOME in Linux in this article, and these steps should also work with any Linux or Java version like Ubuntu, RedHat, CentOS, SUSE, ArchLinux, Debian, Fedora, etc.
🌐
LYRASIS Wiki
wiki.lyrasis.org › display › FEDORA34 › Setting+JAVA_HOME+in+Windows
Setting JAVA_HOME in Windows - Fedora 3.4 Documentation - LYRASIS Wiki
Enter the variable name as JAVA_HOME. Enter the variable value as the installation path for the Java Development Kit. Click 'OK'. Click 'Apply Changes'. If you are running the Fedora Repository as a WAR rather than the Standalone, you may need to restart your application server.
Top answer
1 of 1
1

If you want to install the Oracle JDK on Fedora you have to options (check your CPU's architecture).

  • Download the tar.gz file from Oracle's website
  • Download the rpm file from Oracle's website

Option 1 - tar.gz

IMHO the easiest and less invasive option is to download the tar.gz file. Let's assume you downloaded the file jdk-8u161-linux-x64.tar.gz. After the download open a terminal and extract the file to an appropriate place, eg a sub folder in your user's home directory /home/myuser/programs by executing

cd /home/myuser/programs
tar -xvzf <PATH-TO-DOWNLOADED-FILE>/jdk-8u161-linux-x64.tar.gz

After that the you have a directory jdk1.8.0_161 in /home/myuser/programs which you can now reference. To have all the binaries in /home/myuser/programs/jdk1.8.0_161/bin available use

export JAVA_HOME=/home/myuser/programs/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH

This sets the environment variable JAVA_HOME to the directory where you extracted all the files and puts all binaries in the sub dir bin into the environment variable PATH.

Test it with:

java -version

The output should be:

java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

After that was successful remember to persist the environment settings by adding them to you ~/.profile file or ~/.bashrc.

Option 2 - rpm file

Discalimer: I have not tested this way.

For this way you need root access. After you downloaded the rpm file you may want to check if all requirements to install the JDK are matched by executing

rpm -i --test  <PATH-TO-DOWNLOADED-FILE>/jdk-8u161-linux-x64.rpm

After that was successfull, change to root (su root) and install the rpm by

rpm -i <PATH-TO-DOWNLOADED-FILE>/jdk-8u161-linux-x64.rpm

Maybe you can also use sudo

sudo rpm -i <PATH-TO-DOWNLOADED-FILE>/jdk-8u161-linux-x64.rpm

After installing the rpm file you maybe have to add the binaries to you PATH variable as above (see option 1).

🌐
FedoraForum
fedoraforum.org › forum › showpost.php
Setting Java PATH in Linux
If you installed your "another version" and then right away ran "locate javac | grep bin" you would not see any hint of your new java installation in the locate output (unless you just happened to run your command by chance right after the cron job runs that updates the locate DB, it does that in Fedora very early in the morning). You can run this as root user to force the update: ... JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64 (or whatever arch you used as the extension) export JAVA_HOME and then logout the GUI and log back in and also use the alternatives --config java command to also point to the new java and then confirm it's correct afterwards by running:
🌐
nixCraft
cyberciti.biz › nixcraft › howto › bash shell › how to set java_home / path variables under linux bash profile
How to Set JAVA_HOME / PATH variables Under Linux Bash Profile - nixCraft
May 25, 2012 - 1) In my case I did all you said for .bash_profile, however, running which java still shows old java path (crappy java that comes with linux fedora 7) 2) I tried the same to set /etc/profile but I believe you provided wrong sintax · Could somebody provide correct sintax for seting java path in /etc/profile or whatever as long as my which java will show my newest java? ... I have read lots of user posting at various pages and none of them would work. Finally, I found a way to do this correctly and hope this will help to some of you. ... echo ‘export JAVA_HOME=/opt/jdk1.5.0_12’ > /etc/profile.d/jdk.sh echo ‘export PATH=$JAVA_HOME/bin:$PATH’ >> /etc/profile.d/jdk.sh
🌐
CodingTechRoom
codingtechroom.com › question › -set-java-home-openjdk-fedora
How to Set JAVA_HOME for OpenJDK on Fedora - CodingTechRoom
Open a terminal window on your Fedora system. Edit the .bash_profile or .bashrc file in your home directory. Add or modify the JAVA_HOME variable to point to your OpenJDK directory. Source the file or restart the terminal to apply changes. Mistake: Setting JAVA_HOME to the wrong path.