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
Related
What I would like is to add Java (installation and JAVA_HOME) in an image.
I'm using this postgres dockerfile: https://github.com/docker-library/postgres/tree/master/9.6
Which I updated with the following :
RUN apt-get -y update
RUN apt-get -y install wget
RUN apt-get -y install sudo
RUN /bin/mkdir /usr/lib/jvm
RUN wget https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz -O /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
RUN sudo tar xfvz /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz --directory /usr/lib/jvm
RUN rm -f /tmp/openjdk-11.0.2_linux-x64_bin.tar.gz
ENV JAVA_HOME /etc/alternatives/jre
Please note that I'm beginner so if something is obvious for you it may not be for me.
The issue is that, /usr/lib/jvm is not created thus java is not installed and also JAVA_HOME is empty when I run the image.
When I execute manually the instructions, it works, but I would like to make my dockerfile working.
I have to run Django CRM in my local machine. I followed all commands and tried to install every dependency.
I got stuck in the following command.
sudo apt-get install oracle-java8-installer -y java -version
I got the following error when I tried above command.
E: Command line option 'e' [from -version] is not understood in combination with the other options.
The link of Github CRM Django CRM
Documentation
Please someone help me.
Looking to Django-CRM documentation, seems like the command to install java (required by elasticsearch dependency) it's not the correct one for ubuntu 18.04
To install it you need to run:
apt-get install openjdk-8-jre-headless
Then you can follow the instructions as in the documentation
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch > key.elastic
apt-key add key.elastic
echo "deb https://packages.elastic.co/elasticsearch/2.x/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
apt-get update && apt-get install elasticsearch -y
Also, remember to add sudo on the commands if you are not running the commands as root
I have a set up of Protractor, for which I need java in my Dockerfile to run the selenium-server.jar file.
Here is my Dockerfile
FROM node:latest
ENV CHROME_VERSION "google-chrome-stable"
RUN sed -i -- 's&deb http://deb.debian.org/debian jessie-updates main&#deb http://deb.debian.org/debian jessie-updates main&g' /etc/apt/sources.list \
&& apt-get -o Acquire::Check-Valid-Until=false update && apt-get -o Acquire::Check-Valid-Until=false install wget -y
ENV CHROME_VERSION "google-chrome-stable"
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list \
&& apt-get -o Acquire::Check-Valid-Until=false update && apt-get -qqy --allow-unauthenticated install ${CHROME_VERSION:-google-chrome-stable}
# Add the dependencies to get the xenial apt sources
RUN echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
RUN echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
RUN apt-get -y update
# Add these silent accept - since oracle installer asks for permission to install java-version-8
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
RUN echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 seen true" | debconf-set-selections
# Install java-8
RUN apt install -y oracle-java8-installer && apt install oracle-java8-set-default
This set up was working fine until yesterday but since then I've been getting this error
download failed
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt install -y oracle-java8-installer && apt install oracle-java8-set-default' returned a non-zero code: 100
Now before marking this question as a duplicate , please see that I have gone through a lot of similar SO posts and applied all the changes mentioned but the error still persists or I get a new error, which circles back to this unable to download error.
I have tried the solutions mentioned in this, this, this and this, this, this, this but haven't been able to solve it.
The complete log file is here. If required, I can post the error that I got when trying to apply the solutions mentioned.
Looking for any pointers to solve this issue.
Do you really need to have oracle jdk? In the pass, I used the content of Dockerfile from openjdk to build an image from node and having java installed: https://github.com/docker-library/openjdk/blob/master/8/jdk/Dockerfile
Nevertheless, in your case, I would build a centralized selenium server or use a directConnect in CI pipeline.
Docker will remember the result of running each command unless you explicitly tell it not to (docker build --no-cache). In particular, it will skip over running the apt-get update step if it thinks it’s already done this.
Meanwhile, the Debian and Ubuntu repositories update frequently, and when they update, they remove old versions of packages. This means that if you’re using yesterday’s version of the package cache, you’ll get “download failed” errors like you see until you re-run apt-get update.
In a Docker context, the correct answer to this is to always run apt-get update and apt-get install in the same RUN step. You might change the end of your Dockerfile to look like
RUN apt-get update -y \
&& apt install oracle-java8-installer oracle-java8-set-default
Once you’ve gotten past the initial development stage it’s probably good practice to just have a single apt install command in your Dockerfile that does one pass at installing all of the runtime dependencies you need.
As in title, I can not install openjdk-7-jdk using dockerfile from Ubuntu 14.04.
At that command RUN apt-get install -y openjdk-7-jdk I get the following error
Unable to fetch some archives, maybe run apt-get update or try with
--fix-missing?
failed to build: The command '/bin/sh -c apt-get install -y
openjdk-7-jdk' returned a non-zero code: 100
Before I already use RUN apt-get update -y && apt-get upgrade -y and additionally I was trying RUN sudo apt-get -f install. I read that people find a way to do this using Packages in the PPA, but it's not recommended because of the lack of security.
Using UBUNTU, I installed java 8 with the following command
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default
and I'm trying to set the java environment path as follow
$ cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL
but I get this error message:
bash: /etc/environment: permission denied
Assuming that you have already the following:
$sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default*
Open /etc/environment file with the following command.
sudo nano /etc/environment
N/B: You can replace nano with any other editor you like e.g atom
At the end of file, add
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
The command above alone worked for me but you can also add the command below if you want.
JRE_HOME="/usr/lib/jvm/java-8-oracle/jre"
Remember the path used here was my java installation directory, if yours is the same then you don't need to change anything, otherwise use your path.
Check whether your changes persisted
$ source /etc/environment
$ echo $JAVA_HOME
https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04
Try this script, save it in a file.sh
#!/bin/bash
sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install openjdk-8-jre -y
sudo cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
EOL
Try with sudo
$ sudo cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL
Use the following lines to set the path variables in the /etc/environment
echo export JAVA_HOME=/path/to/java | sudo tee -a /etc/environment
echo export JRE_HOME=/path/to/jre | sudo tee -a /etc/environment
It should work.
Note:
You should reboot the system for changes to take effect.
And don't forget to come here after reboot and vote +1 :)-|-<
Following is the method that worked for me -
Use bashrc to create environment variable :
JAVA_HOME=/path/to/java
JRE_HOME=/path/to/jre
sudo vim ~/.bashrc
Enter Password
Press I(Key) to go in the insert mode
Write export JAVA_HOME='/path/to/java' at the end of file
Write export JRE_HOME='/path/to/jre' at the end of file
Save and Exit (:wq)