How to set the JAVA_HOME environment variable?
Environment
- Red Hat middleware products
- Red Hat Enterprise Linux (RHEL)
- JDK
Issue
- To run JBoss product, I need to set the
JAVA_HOME
environment variable, how to set it? - How do I set the
JAVA_HOME
environment variable?
Resolution
Generally JAVA_HOME
is needed to run the Java-related applications, else the results may vary. To manually set up the JAVA_HOME
environment variable follow the steps:
- Determine the correct value for
JAVA_HOME
. It should point to the directory containing abin/java
executable. - As the user who will use OpenJDK or any JDK vendor, open the shell configuration file. For the bash shell, this file is
/home/username/.bashrc
. - At the bottom of the file, type the following line, replacing the hypothetical path with the actual path to use on the operating system:
export JAVA_HOME="/path/to/java/home"
. - Save the file and reload the shell configuration, i.e,
source ~/.bashrc
- The
echo $JAVA_HOME
command-line must return the complete path directory tojava
executable.
For detailed instructions, please see JBOSS Enterprise Application Platform Installation Guide: Install OpenJDK on Red Hat Enterprise Linux
For usage of alternatives
command-line tool, see solution Switching JAVA_HOME using alternatives.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments