![]() ![]() In my case, Java 8 is currently active so I entered 1 in the selection to change it to Java 11. Select the appropriate Java version number and press enter. To list the available Java versions, you can use the following command: sudo alternatives -config javaĪ list of installed Java versions will be displayed. If you need to manage multiple versions of Java on your server, you can use the alternatives command to switch between different versions. ![]() Print JAVA_HOME and PATH environment variables Step 5: Switch Between Java Versions This will print the values of the JAVA_HOME and PATH environment variables. Now, you can check that the environment variables have been set correctly by typing: echo $JAVA_HOME echo $PATH This will set the JAVA_HOME environment variable and add the Java binary directory to the PATH variable.Īfter you’ve saved the changes to the bash_profile file, you need to reload the file: source ~/.bash_profile Setting JAVA_HOME and PATH in ~/bash_profile file Once you’ve opened the file, you need to add the following lines at the end of the file: export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk To set up your environment variables, you need to edit the “~/.bash_profile” file: nano ~/.bash_profile ![]() This will ensure that all the Java applications you run will be able to find the correct version of Java. Once you’ve installed Java on your server, you need to set up the Java Environment Variables. Step 4: Setting Up Java Environment Variables This will print the version of Java that has been installed on your server. OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode) OpenJDK Runtime Environment (build 1.8.0_222-b10) After you have installed the JDK or JRE, you can check the version of Java that has been installed by typing: java -version I have installed both Java versions for this article, First I installed Java 11 then installed Java 8 on my CentOS 8 system. To install the JRE, you can use the same command as you used to install the JDK but with the “-jre” flag: sudo dnf install java-1.8.0-openjdk-jre Step 3: Check Java Version ![]() The JRE is a stripped-down version of Java that is used to run Java applications. You can also install the Java Runtime Environment (JRE) if you don’t need the full JDK. Install Latest Java: This will install the latest available Java version on your system.Install Java 17: which is the current LTS release.Install Java 8: which is still being used by large number of applications.Install Java 11: which is the current popular version among developers.To download the JDK on CentOS/RHEL 8, you can use the command line: You can choose any of the available Java versions to install on your CentOS 8 or RHEL 8 systems. During the last update of this tutorial Java 1.8, Java 11, Java 17, and Java 19 (latest) version were available for installation. You can also install both Java versions on any system and use them as per your requirements. Now, use one of the following commands to install the required Java version on your CentOS 8 and RHEL 8 Linux systems. The JDK is the most comprehensive version of Java and contains all the necessary tools for developing Java applications. The first step in installing Java on CentOS/RHEL 8 is to download the Java Development Kit (JDK). sudo dnf search openjdk Search available Java package versions Step 2: Install Java on CentOS 8 Use the following command to search available Java packages under configured DNF repositories. The OpenJDK rpm packages are available under the AppStream repository. Advertisement Step 1: Search Java Packages ![]()
0 Comments
Leave a Reply. |