gpt4 book ai didi

java - purge 不会卸载 java 6?

转载 作者:太空宇宙 更新时间:2023-11-04 14:01:20 27 4
gpt4 key购买 nike

我正在使用Vagrant模拟分布式系统项目的网络。我使用此文件 provision.sh 来配置集群中的每台计算机:

sudo apt-get update
sudo apt-get install -y openjdk-7-jdk
sudo apt-get purge -y openjdk-6-jre
sudo apt-get purge -y openjdk-6-jre-lib
sudo apt-get install -y maven
echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386" >> /home/vagrant/.profile
echo "export PATH=$JAVA_HOME/bin:$PATH" >> /home/vagrant/.profile
mvn clean -f /vagrant/RaftFS/pom.xml
mvn package -f /vagrant/RaftFS/pom.xml
sudo mv /vagrant/RaftFS/target/RaftFS-1.0-SNAPSHOT-jar-with-dependencies.jar /vagrant/
sudo cp /vagrant/RaftFS/servers.yaml /vagrant/

但是当我访问虚拟机并运行 java -version 时,它说版本 6 仍然安装!这怎么可能?正如 @ydaetskcoR 所建议的,如果我执行 env | grep JAVA_HOME 它返回JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 ...所以我不明白为什么它说java版本是6

为了完整起见,这是 Vagrant 文件:

# -*- mode: ruby -*-
# # vi: set ft=ruby :

# Specify minimum Vagrant version and Vagrant API version
Vagrant.require_version ">= 1.6.0"
VAGRANTFILE_API_VERSION = "2"

# Require YAML module
require 'yaml'

# Read YAML file with box details
servers = YAML.load_file('RaftFS/servers.yaml')

# Create boxes
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

# Iterate through entries in YAML file
servers.each do |key,value|
config.vm.define key do |srv|
srv.vm.box = value['box']
srv.vm.network "private_network", ip: value['ip']
srv.vm.hostname=key
srv.vm.synced_folder ".", "/vagrant" , disabled:true
srv.vm.synced_folder "ServersFS/"+key+"/", "/vagrant/ServersFS" , create: true
srv.vm.synced_folder "./RaftFS", "/vagrant/RaftFS"
srv.vm.provision :shell, path: "provision.sh"
srv.vm.provider :virtualbox do |vb|
vb.name = key
vb.memory = value['ram']
end
end
end
end

这是servers.yaml 文件:

hal9000:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.101
ftpPort: 8080
skynet:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.102
ftpPort: 8081
jarvis:
box: hashicorp/precise32
ram: 512
ip: 172.17.8.103
ftpPort: 8083

最佳答案

安装新的 Java 版本后,您必须告知系统您的 Oracle Java JDK/JRE 所在位置,并且必须使用默认版本。这将告诉系统新的 Oracle Java 版本可供使用。

为此,您必须使用“update-alternatives”,如下所示:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_20/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_20/bin/javac" 1
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_20/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_20/bin/javac

更改 openjdk-7-jdk 文件的路径

关于java - purge 不会卸载 java 6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29285152/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com