purge doesn't uninstall java 6? - java

I'm using Vagrant to simulate a network for a distributed system project. I'm using this file provision.sh in order to provision each machine in the cluster:
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/
But when I access to the VM and I run java -version it says that the version 6 is still installed! How is that possible? As suggested by #ydaetskcoR if I execute env | grep JAVA_HOME it returns JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386 ...so I don't get why it says that the java version is 6
Just for completeness, this is the Vagrant file:
# -*- 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
and this is servers.yaml file:
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

After installing new Java version, you must to inform your system where your Oracle Java JDK/JRE is located and with version must be used as default. This will tell the system that the new Oracle Java version is available for use.
For this you must use "update-alternatives", something like this:
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
Change paths to your openjdk-7-jdk files

I found out by myself the answer to my problem: I had simply to update the system's alternatives with these two commands:
sudo apt-get install icedtea-7-plugin
sudo update-java-alternatives -s java-1.7.0-openjdk-i386
The first one is necessary since this error would be thrown otherwise:
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so
Now if I run java -version the correct version (7) is returned.

Related

update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting

I am trying to install Java Developer Kit 8 by running the following commands:
sudo apt-get update
sudo apt-get install -y openjdk-8-jdk
echo 'Updating eventually the correct version of Java...'
var=$(java -version 2>&1 | awk -F '"' 'NR==1 {print $2}') # get the actual version
sudo update-alternatives --set java /usr/lib/jvm/jdk${var}/bin/java
The problem is that I am getting the following error:
default: Updating eventually the correct version of Java...
update-alternatives: error: alternative /usr/lib/jvm/jdk1.8.0_312/bin/java for java not registered; not setting
Is there a missing step in the commands?
I'm somewhat confused. You're directly invoking the java command, which will use the java that's already redirected in in the alternatives configuration. You are literally attempting to set the default java to the java that you've just installed? If you don't change anything, then it should already be pointing to this instance of java.
Secondly, you're assuming that the path to java is the one you're specifying there. It doesn't have to be the case. When I create a minimal docker container with openjdk-8-jdk (and dpkg, so update-alternatives is available), then the path to java is:
root#c330511a7cde:/# update-alternatives --list java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
So the path that you should have been using was this path.
Now I've manually installed a few more java versions, and because of priorities, java-17 is now the default java, so the output is a bit longer:
root#c330511a7cde:/# update-alternatives --list java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java
/usr/lib/jvm/java-17-openjdk-amd64/bin/java
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
In this case, you're probably better finding the java-8 path from update-alternatives and setting it that way, so something like:
java_8_path=$(update-alternatives --list java | grep 'java-8-openjdk' | head -1)
if [ -n "$java_8_path" ]; then
sudo update-alternatives --set java "$java_8_path" || echo "darn"
else
echo "could not find java8 in alternatives list" 1>&2
fi

Install java 8 (jdk 1.8) using "vagrant up" not working on debian

When I am Running My Vagrantfile with its shell, I'm struggle with Java 8 install with this exact same error :
StackOverflow - jdk-8-is-not-installed-error-404-not-found
In order to fix that error, I added those lines :
sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
I have in my Shell this block for java section:
# /*======================
# = JAVA =
# ======================*/
# https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-debian-8
sudo apt-get install -y software-properties-common
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee /etc/apt/sources.list.d/webupd8team-java.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/webupd8team-java.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
sudo apt-get update
# Silent !! Sshh !
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
# see https://stackoverflow.com/questions/46815897/jdk-8-is-not-installed-error-404-not-found
# Still not work
sudo sed -i 's|JAVA_VERSION=8u151|JAVA_VERSION=8u162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|SHA256SUM_TGZ="68ec82d47fd9c2b8eb84225b6db398a72008285fafc98631b1ff8d2229680257"|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_151|J_DIR=jdk1.8.0_162|' /var/lib/dpkg/info/oracle-java8-installer.*
sudo apt-get install -y oracle-java8-installer
sudo apt-get install -y oracle-java8-set-default
The weird thing is : Those lines taken one by one via SSH when the box is started and you can install Java, it Works. But it's not working when I provision for the first time my vagrant box.
Is the problem comes from sed or another command ? I suppose it's the sed's command but don't know how to fix it, because it's working if I paste them via SSH.
I want to make this work without any manual interventions.
You can test my VM using this github repo (V2) :
VagrantFile + shells
How can I make this work using vagrant up ?
EDIT :
I've tested it on Vagrant 2.0 and virtualBox 5.6
Also tested with vagrant 1.7 and virtualBox 5.1
I'm putting this in just in case anyone is fine with Debians basic version, but has missed it. I think it should already be installed on anything but the most bare-bones systems.
To get openJDK working, which is the version offered in Debians standard repos, you would just need to use
apt-get install -y openjdk-8-jdk
There are other debug and docs packages as well.
Debian also provide a package in the contrib repos called java-package which converts the source tarball from the Oracle site (you have to get it yourself to OK the terms and conditions), and creates a deb from it. Unfortunately there doesn't seem to be a way to directly presume yes to the questions asked, so it would need an expect script or something.
config.vm.provision "shell", inline: <<-SHELL
# add contrib repos into source files.
mv /etc/apt/sources.list /etc/apt/sources.bk
sed -r ‘s/stretch([^ ]*) main$/& contrib/‘ /etc/apt/sources.bk | sudo tee /etc/apt/sources.list
# vi -c ':%s/stretch\([^ ]*\) main$/& contrib/g' /etc/apt/sources.list -c 'wq'
apt-get update
apt-get install -y java-package java-common expect
# some `expect` needed magic here
sudo -u vagrant fakeroot make-jpkg /vagrant/jdk-8*
dpkg -i oracle-java8*
SHELL
In terms of the interactions I get using make-jpkg, this script works (from the command line)
expect -c '
set timeout -1
spawn fakeroot make-jpkg /vagrant/jdk-8u162-linux-x64.tar.gz
expect "Is this correct \\\[Y/n\\\]: $" { send "Y\r" }
expect "Press \\\[Return\\\] to continue: " { send "\r" }
expect "*Press \\\[Return\\\] to continue or Ctrl-C to abort." { send "\r" }
expect eof { exit 0 }
'
but could probably be done other ways.
So almost an answer, but may get you a bit closer.
Sorry for my late answer. Another option is to mount a drive and install the oracle rpm package silently.
Create directory and put there your Vagrantfile. This the root of your project. (./)
Vagrantfile
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "bento/centos-7.4"
config.vm.boot_timeout = 240
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# View the documentation for the provider you are using for more
# information on available options.
config.vm.provider "virtualbox" do |vb|
# Enable the Host I/O cache for more performance
vb.customize [
"storagectl", :id,
"--name", "SATA Controller",
"--hostiocache", "on"
]
vb.auto_nat_dns_proxy = false
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "off"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "off"]
vb.customize ["modifyvm", :id, "--nictype1", "virtio"]
vb.customize ["modifyvm", :id, "--nictype2", "virtio"
vb.customize ["modifyvm", :id, "--memory", 4096]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.cpus = 4
end
# Synced folders are configured within your Vagrantfile using the config.vm.synced_folder method.
# Vagrant shares by default the root directory of (./) with guest on /vagrant
config.vm.synced_folder ".", "/vagrant", disabled: true
# Synced folder is set as read-only for guest machine. You can configure the files on the host machine.
# For more mount options check: http://manpages.ubuntu.com/manpages/precise/man8/mount.vboxsf.8.html
config.vm.synced_folder "./installfiles", "/installfiles",
owner: "vagrant", group: "vagrant", mount_options: ["ro"]
# Bootstrap shell scripts.
config.vm.provision "shell", path: "./bootstrap/setup.sh"
config.vm.post_up_message = "Finsihed provisioning!\n" \
"Type \"vagrant ssh\" to get started"
end
Create another directory named bootstrap from the root of your project. Create an empty file called setup.sh, put the content below in the setup.sh file. The file path will be ./bootstrap/setup.sh
setup.sh
#!/usr/bin/env bash
echo "installing Java 8 64 bit"
sudo rpm -i /installfiles/java8/jdk-8u144-linux-x64.rpm
unzip /installfiles/java8/jce_policy-8.zip -d /tmp
sudo cp -f /tmp/UnlimitedJCEPolicyJDK8/* $JAVA_HOME/lib/security/
Go to the oracle website download the correct 32 or 64 bit rpm linux package. Versions available on the oracle website might change. For this example i downloaded the jdk-8u144-linux-x64.rpm package. I also downloaded the unlimited encryption strength policy from the oracle website, name of the file is: jce_policy-8.zip.
Create two directories from the root of your project named installfiles/java8. Place the downloaded files in there. The files path will be: ./installfiles/java8/jdk-8u144-linux-x64.rpm and ./installfiles/java8/jce_policy-8.zip
Run the command vagrant up. On your host machine the directory ./installfiles will be synchronised with your virtualbox guest machine on the path /installfiles. During the provisioning state of vagrant java-8 will be installed automatically. Keep in mind that the rpm package manager comes out of the box with Red Hat distros. But it is also possible to install rpm packages on debian distros.
The following snippet fixes the silent install of java from webupd8team repo for Debian distribution
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y ppa:webupd8team/java
sudo bash -c "echo deb http://http.debian.net/debian jessie-backports main >> /etc/apt/sources.list"
sudo bash -c "echo deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main >> /etc/apt/sources.list.d/webupd8team-java.list"
sudo bash -c "echo deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main >> /etc/apt/sources.list.d/webupd8team-java.list"
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
sudo apt-get update
sudo apt-get -y upgrade
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selectionssudo
sudo apt-get -y install oracle-java8-installer oracle-java8-set-default
As of today, it installs the following
vagrant#debian-8:~$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

oracle-java8-installer Webupd8 PPA 404 Not Found

The following error is thrown when you execute sudo apt-get install oracle-java8-installer:
Location: http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508340360_7be4aa21e145dd26bda475add7c27ada [following]
--2017-10-18 08:24:00-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz?AuthParam=1508340360_7be4aa21e145dd26bda475add7c27ada
Reusing existing connection to 2.2.0.1:8080.
Proxy request sent, awaiting response... 404 Not Found
A temporarily workaround is:
cd /var/lib/dpkg/info
sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/|' oracle-java8-installer.*
sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*
From https://ubuntuforums.org/showthread.php?t=2374686 below is reported the ansible playbook to install oracle-java8-installer implementing the workaround illustrated in the above answer (also coming from the same source, supposedly).
---
- name: Add Oracle Java webupd PPA
apt_repository:
repo: "ppa:webupd8team/java"
- name: Accept Java licence
debconf:
name: "oracle-java{{ java.version }}-installer"
question: shared/accepted-oracle-license-v1-1
vtype: select
value: "true"
# - name: Install Oracle Java
# apt:
# name: "{{ item }}"
# update_cache: yes
# state: latest
# force: yes
# with_items:
# - "oracle-java{{ java.version }}-installer"
# - "oracle-java{{ java.version }}-set-default"
# Temporary fix for webupd8team installer issue
- name: Install Oracle Java
block:
- apt:
name: "{{ item }}"
update_cache: yes
state: latest
force: yes
with_items:
- "oracle-java{{ java.version }}-installer"
- "oracle-java{{ java.version }}-set-default"
rescue:
- shell: cd /var/lib/dpkg/info && sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u152|' oracle-java8-installer.*
- shell: cd /var/lib/dpkg/info && sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u152-b16/aa0333dd3019491ca4f6ddbe78cdb6d0/|' oracle-java8-installer.*
- shell: cd /var/lib/dpkg/info && sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="218b3b340c3f6d05d940b817d0270dfe0cfd657a636bad074dcabe0c111961bf"|' oracle-java8-installer.*
- shell: cd /var/lib/dpkg/info && sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_152|' oracle-java8-installer.*
always:
- apt:
name: "{{ item }}"
with_items:
- "oracle-java{{ java.version }}-installer"
- "oracle-java{{ java.version }}-set-default"
Late answer but I just found out another way to install java without any problems.
Just install openjdk 8
apt-get install openjdk-8-jre-headless
then test it through
java -version
See also:
https://www.youtube.com/watch?v=fdB5dhPXiXc
The ppa is great and I appreciate the work put into it. Recently oracle changed the paths and the ppa needs to be updated until it works again. In the mean time I found this workaround from the ubuntu forum helpful to install jdk8 (I removed the docker specific stuff):
### workaround to install oracle jdk8 until ppa will be updated
# install java via wget site oficial oracle
# note: JAVA_FILE_TAR, JAVA_URL_DOWNLOAD and JAVA_DIR must be entered manually
export JAVA_FILE_TAR=jdk-8u191-linux-x64.tar.gz
export JAVA_URL_DOWNLOAD="http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/${JAVA_FILE_TAR}"
export JAVA_DIR=jdk1.8.0_191
# download and extract tar
cd /opt
wget -q --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" ${JAVA_URL_DOWNLOAD}
tar zxvf ${JAVA_FILE_TAR} && pwd && ls -la
# set default java
update-alternatives --install /usr/bin/java java /opt/${JAVA_DIR}/bin/java 1
update-alternatives --install /usr/bin/javac javac /opt/${JAVA_DIR}/bin/javac 1
update-alternatives --install /usr/bin/jar jar /opt/${JAVA_DIR}/bin/jar 1
# set temp env vars
export JAVA_HOME=/opt/${JAVA_DIR}
export PATH=$PATH:/opt/${JAVA_DIR}/bin:/opt/${JAVA_DIR}/jre/bin
echo "export JAVA_HOME=/opt/${JAVA_DIR}" >> /etc/environment
echo "export PATH=$PATH:/opt/${JAVA_DIR}/bin:/opt/${JAVA_DIR}/jre/bin" >> /etc/environment

WSO2 Identity Server - Carbon cannot execute Java

I'm using Ubuntu 16.04 64-bit. I installed Oracle JDK jdk1.8.0_144 in /usr/local/java and set the symlinks as below.
$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_144/jre/bin/java" 1
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_144/bin/javac" 1
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_144/jre/bin/javaws" 1
$ sudo update-alternatives --set java /usr/local/java/jdk1.8.0_144/jre/bin/java
$ sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_144/bin/javac
$ sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_144/jre/bin/javaws
After that, I followed the installation guide in the WSO2 documentation and set JAVA_HOME as below.
nano /.bashrc
added the variable:
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export PATH=${JAVA_HOME}/bin:${PATH}
I close the old terminals and open a new one and run:
echo $JAVA_HOME
and I get
/usr/local/java/jdk1.8.0_144
However, when I run sh wso2server.sh I get the error:
JAVA_HOME is not defined correctly.
CARBON cannot execute java
error.
You should try to add the following into your .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/jre/bin:$PATH
There is similar issue: Ubuntu: JAVA_HOME is not defined correctly
There are many other causes of this issue:
1) You are running the server as the super user (sudo) which is not required. However I think you dont have the JAVA_HOME set in super user environment.
2) You can try: sudo JAVA_HOME=/usr/lib/jvm/java-7-oracle ./wso2server.sh
3) You should probably be setting JAVA_HOME to /usr/lib/jvm/jdk1.7.0/jre rather than /usr/lib/jvm/jdk1.7.0.
4) Your version of Identity Server does not support java 8.
replace your java home path in wso2server.sh line no 52
#JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

How to set java-7-oracle as default java version?

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
I tried to install oracle-java7 on my Linux Mint with the codes above. After executing those codes, I tried to check if its working by typing "java -version" but suddenly an error occured.
bash: /usr/bin/java: cannot execute binary file: Exec format error
You can install a package to set (and keep) oracle-java7 as the default; or you can manually set the java alternative with update-java-alternatives. Something like,
Option 1. sudo apt-get install oracle-java7-set-default
Option 2. sudo update-java-alternatives -s java-7-oracle

Categories

Resources