As a Java-based framework, your SpringBoot development environment and deployment environment must have the JAVA_HOME and JRE_HOME environment variables configured correctly.
The following will take you through the general CentOS 7.x Java installation, and focus on how to set these environment variables, and verify they are pointing to the Java distribution.
- General Linux administrative and command knowledge
- sudo privileges on the target CentOS system, as we shall be installing and configuring software
- FTP client, either at your remote desktop workstation, or on the target CentOS system
- A recent yum -update is always helpful
- I also recommend taking a snapshot of your target development CentOS virtual machine before installing major software components or adjusting critical configuration settings.
- See disclaimer
1. Installation Procedure:
- Make a working directory to download the latest Java distribution:
cd /opt mkdir java
- At your workstation, download the latest version of java SE RPM.
> At the time of this article, this is jdk-8u151-linux-x64.rpm
> At the time of this article, the download url is:
- Using your FTP client of choice, download the rpm to /opt/java
- Return to the dev server SSH console. Install the rpm using yum as follows:
cd /opt/java yum localinstall jdk-8u151-linux-x64.rpm
2. Adding JAVA_HOME and JRE_HOME to /etc/bashrc
- Using nano, open /etc/bashrc to add the following java environment variables.
- Scroll to bottom of the /etc/bashrc file.
- Add the following lines to set the JAVA_HOME and JRE_HOME environment variables to the /usr/bin location. The yum rpm install above set a series of symbolic links in the /etc/alternatives which were also set in /usr/lib … the full path is:
... # Java and JRE export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-184.108.40.206-1.b12.el6_9.x86_64/jre export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-220.127.116.11-1.b12.el6_9.x86_64/jre PATH=$PATH:$JAVA_HOME:$JRE_HOME
- Reload your bash environment settings, including the new path variables, by:
- Test your java environment. At prompt type the following:
java -version echo $JRE_HOME echo $JAVA_HOME
And that’s it. The console should now display your paths to Java, which will allow you to execute java -jar to load your SpringBoot executables. Thanks, Like and Link! paulsDevBlog.End();