编程知识 cdmana.com

Installation and configuration of JDK (RPM mode and tar.gz Method)

It used to be in Windows Environment development , Recently, due to the need of work ; Learning in Linux Build the development environment under the system , From then on, record the build process , For easy reference .

This article draws on  Angel A squeeze  、 Xiao Wu   Two blogs .

 

Prepare the material :

  JDK Download link : Download link on official website ( Need to log in )

          Personal offer - edition 8u271( Nut cloud )

   Terminal simulator :MobaXterm ( Free open source ; There is no need to install this item , But directly in Linux Operating in the system )

  Linux System version :CentOS7

   user :root user ( There may be problems in the operation of ordinary users , Please Baidu

 

Construction process :

   View and delete the system's own openjdk

   Through the command :java -version View installed JDK Version information

          

   Find installed JDK Related documents

     rpm -qa | grep java ( System native openjdk Use this command )

     rpm -qa | grep jdk ( Self installing JDK Use this command )

          

   Use the following command to uninstall the installed JDK(*.noarch file You can ignore ):

    rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el7_ 8.x86_64

    rpm -e --nodeps java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64

     notes :1. Use rpm -e --nodeps command , It will be deleted synchronously JDK The installation directory

      2. rpm -qa | grep command , Yes tar.gz How to install JDK Invalid

      3. tar.gz Installed by JDK You need to uninstall ( Delete )

         First , adopt echo $JAVA_HOME Command to determine JDK The installation directory ;

         then , adopt rm -rf  /usr/java/jdk1.8.0_271 Delete this directory

         Last , adopt vim /etc/profile The order will “JAVA_HOME” Empty after the equal sign ( Purpose : Disassociate )

   Verify that the deletion was successful ( A red sign appears , Indicates that the uninstall was successful ):

    java -version

    

 

  rpm The way

     First step : By any means , Will download "jdk-8u271-linux-x64.rpm" Files in Linux In the system

     The second step : Start the installation by command ( After installation , It can be done by java -version Command confirmation is successful )

      chmod 755 jdk-8u271-linux-x64.rpm (chmod yes Linux Set file permissions under the command ,755 Means to read 、 Can write 、 Executable ;root Under the user , It doesn't seem necessary )

      rpm -ivh jdk-8u271-linux-x64.rpm

      

      The third step :rpm Default installation path (/usr/java/jdk1.8.0_271-amd64

      

      Step four : Configure environment variables

       Through the command vim /etc/profile, Will install new jdk Table of contents assigned to JAVA_HOME

      

      Step five : Through the command  source /etc/profile Make the profile effective immediately , And verify that the configuration is successful (echo $JAVA_HOME

       Whether the content of the red logo is related to its own jdk The installation path is consistent

      

      Step six : Execute at the terminal  java、javac confirm JVM Be able to function

  

  tar.gz The way

              First step : By any means , Will download "jdk-8u271-linux-x64.tar.gz" Files in Linux In the system

     The second step : By order will jdk-8u271-linux-x64.tar.gz Unzip to the path you want to install

      tar -xzvf /root/ download /jdk-8u271-linux-x64.tar.gz -C /usr/java

       notes :-C The path that follows must be real ( If it doesn't exist, it can be done by  mkdir -p   Create file paths with cascading relationships (-p Create the folder layer by layer according to the path ))

     The third step : Configure environment variables

       Through the command  ls -al /usr/java  Check the newly created jdk Installation folder ; Assign the file path to /etc/profile Of documents JAVA_HOME

      

      Step four : Through the command  source /etc/profile  Make the profile effective immediately , And verify that the configuration is successful (echo $JAVA_HOME

     Step five : Execute at the terminal  java、javac confirm JVM Be able to function

      

版权声明
本文为[Jinwen0324]所创,转载请带上原文链接,感谢

Scroll to Top