今天在centos下运行eclipse c++出现来点问题。主要原因是jdk点安装以及环境变量始终不对。

尝试在/etc/profile中手动配置,也没有成功。

做了如下步骤成功解决。

1.查看jdk安装版本,命令是: rpm -qa | grep jdk,运行结果如下

java-1.8.0-openjdk-1.8.0.144-0.b01.el6_9.x86_64
jdk-9-9-ga.x86_64
java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64
java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64
java-1.8.0-openjdk-devel-1.8.0.144-0.b01.el6_9.x86_64
java-1.8.0-openjdk-headless-1.8.0.144-0.b01.el6_9.x86_64

2.删除版本9和1.6,命令是
yum -y remove jdk-9-9-ga.x86_64
yum -y remove java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64
问题得到解决。

安装1.8点步骤在删除版本之前就做了,命令如下,这步比较关键。免去手动设置环境变量点麻烦.

[root@localhost softwares]# yum install java-1.8.0-openjdk-devel

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.sohu.com
 * extras: mirrors.sohu.com
 * updates: mirrors.sohu.com
gitlab_gitlab-ce/signature                              |  836 B     00:00     
gitlab_gitlab-ce/signature                              | 1.0 kB     00:00 ...
gitlab_gitlab-ce-source/signature                       |  836 B     00:00     
gitlab_gitlab-ce-source/signature                       |  951 B     00:00 ...
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.144-0.b01.el6_9 will be installed
--> Processing Dependency: java-1.8.0-openjdk = 1:1.8.0.144-0.b01.el6_9 for package: 1:java-1.8.0-openjdk-devel-1.8.0.144-0.b01.el6_9.x86_64
--> Processing Dependency: libawt_xawt.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.144-0.b01.el6_9.x86_64
--> Processing Dependency: libawt_xawt.so()(64bit) for package: 1:java-1.8.0-openjdk-devel-1.8.0.144-0.b01.el6_9.x86_64
--> Running transaction check
......

05-11 15:57