I have tried multiple releases from here using :
sudo -i
cd /usr/lib/jvm
wget [release link here]
tar xzf [file name here]
export PATH=$PWD/[dir here]/bin:$PATH
java -version
But after java -version I always get:
/usr/lib/jvm/[dir here]/bin/java: cannot execute binary file: Exec format error
Which means I have chosen the wrong release/architecture. Is there a release that works with Raspberry Pi's or is there another way to install Java 16?
Answering my own question.
cd [minecraft directory here]
wget https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk16u-2021-05-08-12-45/OpenJDK16U-jdk_arm_linux_hotspot_2021-05-08-12-45.tar.gz
tar xzf OpenJDK16U-jdk_arm_linux_hotspot_2021-05-08-12-45.tar.gz
export PATH=$PWD/jdk-16.0.1+4/bin:$PATH
java -version
You might have to do
export PATH=$PWD/jdk-16.0.1+4/bin:$PATH
after a reboot
Related
I am trying to configure Alpine with Oracle JDK. I have downloaded the JDK and am copying it into my image and using it there.
When I run which java it reports back the correct path /jdk-11.0.10/bin/java but when I try to run any java command it says it is not found.
I tried to reference some info from
https://wiki.alpinelinux.org/wiki/Installing_Oracle_Java
WRT how to do this but I'm not having any luck.
Any input would be appreciated!
FROM alpine
RUN apk add freetype fontconfig paxctl
COPY jdk-11.0.10_linux-x64_bin.tar.gz /
RUN tar -xf jdk-11.0.10_linux-x64_bin.tar.gz
ENV JAVA_HOME /jdk-11.0.10
ENV PATH ${JAVA_HOME}/bin:${PATH}
CMD echo ${PATH}
CMD echo which java
RUN paxctl -c java
RUN paxctl -m java
RUN paxctl -c javac
RUN paxctl -m javac
CMD java -version
I have below function java_install written in a bash script to install java on Linux box, to which I pass jdk-1.7.0_80-linux-x64.tgz as JAVA_PACKAGE.
Now what is happening is java gets installed and works fine only within the script. Once I come out of this script, none of the java functionalities work, not even java -version. Could someone please help me on what I might be missing here? Basically, I just want java to be installed permanently on this box once this script is executed.
java_install() {
local JAVA_PACKAGE=$1
local TMPDIR=/tmp/quickstart
local TARGET=/usr/share
if [ -n "$JAVA_PACKAGE" ] && [ -f "$JAVA_PACKAGE" ]; then
rm -rf $TMPDIR
mkdir -p $TMPDIR
cp $JAVA_PACKAGE $TMPDIR
( cd $TMPDIR && tar fxz $JAVA_PACKAGE && rm $JAVA_PACKAGE )
local JAVA_BASENAME=$(ls -1 $TMPDIR)
mkdir -p $TARGET
if [ -d "$TARGET/$JAVA_BASENAME" ]; then
echo "# Java already installed at $TARGET/$JAVA_BASENAME"
log_info "Java already installed at $TARGET/$JAVA_BASENAME"
else
echo "# Java now installed at $TARGET/$JAVA_BASENAME"
log_info "Java now installed at $TARGET/$JAVA_BASENAME"
mv $TMPDIR/$JAVA_BASENAME $TARGET
fi
rm -rf $TMPDIR
# now create a script to export these settings
export JAVA_HOME=$TARGET/$JAVA_BASENAME
export PATH=$JAVA_HOME/bin:$PATH
else
echo "# cannot find java package to install"
log_error "cannot find java package to install"
fi
}
Use update alternatives within your script to make your java installation available:
sudo update-alternatives --install "/usr/bin/java" "java" "path to you java executable" 1
More information on this topic can be found here: How to use the command update-alternatives --config java.
Alternatively you can write the export commands for JAVA HOME and PATH to your .bashrc from within your script (if using bash). This way the modified variables are available in the bash shell.
I try to install java8 on my Linux server centOS. In /etc/profile
export JAVA_HOME=/root/jdk1.8.0_71/
export PATH=$JAVA_HOME/bin/:$PATH
[root#localhost ~]# echo $JAVA_HOME
/root/jdk1.8.0_71/
[root#localhost ~]# which java
/root/jdk1.8.0_71/bin/java
[root#localhost ~]#
And then I install Cassandra, but it cannot find the java8. And I execute some commands and get
[root#localhost ~]# su cassandra -c "echo $JAVA_HOME"
/root/jdk1.8.0_71/
[root#localhost ~]# su cassandra -c "whereis java"
java: /usr/bin/java /etc/java /usr/lib/java /usr/local/bin/java /usr/share/java /usr/share/man/man1/java.1.gz
[root#localhost ~]# su cassandra -c "which java"
which: no java in (/root/jdk1.8.0_71//bin/:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
I want to know since the PATH is right, why I failed to get java using which java?
And then I create soft link and change the mode of /root/jdk1.8.0_71 to 777
cd /usr/bin
java -> /root/jdk1.8.0_71/bin/java
But it is still not work. Did I miss somethings or make anything wrong?
If the user Cassandra does not have permission on the /root folder then it wont be able to find it. I don't know why would you copy the JDK in the /root folder. My suggestion is to copy the jdk1.8.0_71 in the /opt folder and set the correct permission (owner or group), something like:
cp -r /root/jdk1.8.0_71 /opt
chown -R cassandra.cassandra /opt
Additional, setting paths in the PATH variable should not include the trailing to avoid "/root/jdk1.8.0_71//bin/"
I did these steps without error:
JDK path :
Downloads/jdk-6u37-linux-x64.bin
Commands in Terminal:
mkdir Programs
cd Programs
bash ../Downloads/jdk-6u37-linux-x64.bin
ln -s jdk-6u37-linux-x64 jdk
Set JAVA_HOME and Path:
I added the following lines to the end of the .bashrc file:
export JAVA_HOME=$Home/Programs/jdk
export PATH=:$JAVA_HOME/bin:$PATH
This is the result of executing the command echo $JAVA_HOME:
/Programs/jdk
This is the result of executing the command echo $PATH:
:/Programs/jdk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games1
And the problem is:
This is the result of executing the command
$ java -version
The program 'java' can be found in the following packages:
* default-jre
* gcj-4.6-jre-headless
* gcj-4.7-jre-headless
* openjdk-7-jre-headless
* openjdk-6-jre-headless
Try: sudo apt-get install
I think the problem is that environment variables are case sensitive in linux, so your
export JAVA_HOME=$Home/Programs/jdk
Should be
export JAVA_HOME=$HOME/Programs/jdk
In your echo $JAVA_HOME output you can see that you don't get your /home/yourname prepended...
Hope that helps.
Cheers,
The scripts located here will help you install sun's jdk on Ubuntu. Really useful stuff.
try this command
sudo update-alternatives --config java
This will list all the Java versions installed and configured.
If you see one or more installs, it will give you a list each element starting with a number. Just choose the number that corresponds to the version you want to use by default.
I know how to install java on linux machine using terminal. But i want to automate the installation using Chef Framework. I have two machines M1 and M2. I am on machine M1 and want to install java on machine M2. This is what i do in using terminal....
first i SSH into machine M2, after i do the following things... (in here i download the java files from third party storage.)
Step1:-
cd setup
step2:-
wget http://downloads.company.com/downloads/DevTools/jdk/6.0/jdk-6u31-linux-i586.bin
Step3:-
chmod +x jdk-6u31-linux-i586.bin
Step4:-
yes | ./jdk-6u31-linux-i586.bin
Step5:-
cd /usr/bin
Step6:-
mv java javaorg
Step7:-
cd /usr
Step8:-
ln -s /home/harish/setup/jdk1.6.0_31 java
Step9:-
echo 'export PATH=$PATH:/usr/java/bin' > /etc/profile.d/alljava.sh;echo 'export JAVA_BINDIR=/usr/java/bin' >> /etc/profile.d/alljava.sh;echo 'export JAVA_ROOT=/usr/java' >> /etc/profile.d/alljava.sh;echo 'export JAVA_HOME=/usr/java' >> /etc/profile.d/alljava.sh;echo 'export JRE_HOME=/usr/java/jre' >> /etc/profile.d/alljava.sh
Step10:-
source /etc/profile.d/alljava.sh
Step11:-
echo $JAVA_HOME
Step12:-
java -version
I have following questions:
what is the category of the problem (chef-solo or shef-server)
do i need to have machine M2 installed Chef.
i have downloaded the cookbook for JAVA from GitHub but i don't know what to do with that.
i have written some code for installing java on SAME machine.. but it also not working..
CODE:
#cookbook/java/recipe/default.rb
*####This will install JAVA on machine M1######*
execute "copy" do
cwd "/home/user/setup"
command "wget http://downloads.company.com/downloads/DevTools/jdk/6.0/jdk-6u31-linux-i586.bin"
end
execute "change_mode" do
command "chmod +x jdk-6u31-linux-i586.bin"
end
execute "dont_know" do
command "yes | ./jdk-6u31-linux-i586.bin"
end
execute "make link" do
command "ln -s /home/harish/setup/jdk1.6.0_31 java"
end
java_home = "export JAVA_HOME=/usr/java/jdk1.6.0_31"
path = "export PATH=$PATH:JAVA_HOME/bin"
file "/etc/profile" do
content "#{java_home}\n#{path}"
owner "root"
end
but this code is giving some big messages..(errors).
can anybody help through this and also how to use the downloaded cookbooks for JAVA.. thanks. :)
This is a long out-of-date question, but I'll include an answer in case someone stumbles in on this one.
Opscode has a Java cookbook that they maintain that can install either OpenJDK or Oracle JDK. It's available at the opscode community site here.
You can use it by adding a dependency to your cookbook's metadata.rb:
depends "java", "~> 1.10.2"
and including the recipe in your cookbook's default.rb:
include_recipe "java"