Solve the “cannot execute binary file: Exec format error” under linux (uninstall and install jdk under centos)

I'm stuck with this problem for a long time and can't solve it. In fact, the jdk is not installed properly. Please uninstall it before installing and reinstall

Ideas

Use yum to install jdk

Before installation: uninstall jdk first

1. Uninstall

Check whether the system comes with jdk

rpm -qa |grep java
rpm -qa |grep jdk 
rpm -qa |grep gcj

If there is output information, the batch uninstall system comes with

rpm -qa | grep java | xargs rpm -e --nodeps
rpm -qa | grep jdk | xargs rpm -e --nodeps

2. Installation

Check which installation packages are available in jdk

yum list java-1.8*

Insert picture description here
Installation package

yum install java-1.8.0-openjdk* -y



```bash
3、配置环境变量

yum install java-1.8.0-openjdk* -y

vi /etc/profile

Insert picture description here

export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk
export PATH=${JAVA_HOME}/bin:$PATH

备注:修改环境变量键盘操作 按(a)  结束环境变量修改 按esc键 和(:wq!)

Insert picture description here
Execute the command: The configured environment variable takes effect

source /etc/profile

4. Check whether the installation is successful

java -version

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_41665637/article/details/113113279