I have installed java11 using
brew install java11
Then I tried the below to get JAVA_HOME
echo $JAVA_HOME
It returned empty .
so following the instructions in echo $JAVA_HOME returns nothing
when I have run ls -l /usr/bin/java
i cannot see any jvm path as shown in the above link. Below is what I got
~ % ls -l /usr/bin/java
-rwxr-xr-x 1 root wheel 168432 Dec 8 05:09 /usr/bin/java
ls -l /usr/lib/jvm/
ls: /usr/lib/jvm/: No such file or directory
How to set JAVA_HOME
If you're using bash, all you have to do is:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile
If you're using zsh (which probably means you're running macOS Catalina or newer), then it should instead be:
echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.zshrc
In either case, restart your shell.
If you have multiple JDK versions installed and you want it to be a specific one, you can use the -v flag to java_home like so:
echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile
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
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 follow the steps largely from https://www.digitalocean.com/community/tutorials/how-to-install-apache-tomcat-8-on-ubuntu-14-04
Let me iterate the steps I took:
i logged in as ubuntu user
sudo apt-get install tomcat8
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat tomcat
cd ~
wget http://apache.mirrors.ionfish.org/tomcat/tomcat-8/v8.0.24/bin/apache-tomcat-8.0.24.tar.gz
sudo mkdir /opt/tomcat
sudo tar xvf apache-tomcat-8*tar.gz -C /opt/tomcat --strip-components=1
cd /opt/tomcat
sudo chgrp -R tomcat conf
sudo chmod g+rwx conf
sudo chmod g+r conf/*
sudo chown -R tomcat work/ temp/ logs/
sudo update-alternatives --config java and selected /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
sudo nano /etc/init/tomcat.conf
and typed
description "Tomcat Server"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid tomcat
setgid tomcat
env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
env CATALINA_HOME=/opt/tomcat
# Modify these options as needed
env JAVA_OPTS="-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
env CATALINA_OPTS="-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
exec $CATALINA_HOME/bin/catalina.sh run
# cleanup temp directory after stop
post-stop script
rm -rf $CATALINA_HOME/temp/*
end script
sudo initctl reload-configuration
sudo initctl start tomcat
which leads to
tomcat start/running, process 14674
But when I go to http://[ip-address]:8080 nothing happens.
Please advise.
UPDATE
One comment below asked me to look at server.xml inside tomcat root folder bin.
I have reproduced the following files:
Which proves that there is no such file inside /opt/tomcat/bin
I have also appended some statements from server.xml below which is inside /opt/tomcat/conf
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Server port="8005" shutdown="SHUTDOWN">
Just use
sudo chown -R tomcat:tomcat /opt/tomcat
This worked for me after useing the very same manual.
If you want clean Ubuntu style package instead, the following should do it...
mkdir $HOME/tomcat8 && cd $HOME/tomcat8
wget http://mirrors.kernel.org/ubuntu/pool/main/e/ecj/libecj-java_3.10.1-2_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/libservlet3.1-java_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/libtomcat8-java_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/tomcat8-common_8.0.28-1_all.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/t/tomcat8/tomcat8_8.0.28-1_all.deb
dpkg -i *.deb
However, you're not on PPA. This isn't managed by apt anymore. You'll need to upgrade it manually whenever an update is made to the packages.
I had the same problem. I installed Oracle JDK 7, HOWEVER, I still used JAVA_HOME in tomcat.conf that was pointing to Open JDK:
env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
Make sure you are using the right version of Java. For me, I set it in tomcat.conf as follows:
env JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
Then, do ps -ef | grep tomcat after re-starting tomcat and you should get something like this if tomcat is running:
tomcat 1580 1 9 14:47 ? 00:00:03 /usr/lib/jvm/java-7-oracle/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/conf/logging.properties -Dja
ger=org.apache.juli.ClassLoaderLogManager -Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Xms128m -Xmx256m -XX:PermSize=128m -XX:MaxPermSize=2
ParallelGC -Djava.endorsed.dirs=/opt/tomcat/endorsed -classpath /opt/tomcat/bin/bootstrap.jar:/opt/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat -Dcat
t -Djava.io.tmpdir=/opt/tomcat/temp org.apache.catalina.startup.Bootstrap start
ubuntu 1607 1423 0 14:48 pts/0 00:00:00 grep --color=auto tomcat
Also, my environment file has the following:
export JAVA_HOME="/usr/lib/jvm/java-7-oracle/jre"
export CATALINA_HOME="/opt/tomcat"
Hope this helps!
Instead of: http://serverip:8080
I used http://localhost:8080
That replacement worked for me.
I have simple solution for installing any version of apache tomcat on Ubuntu.
Simplest Way of Installing any version Apache Tomcat Installation Steps on Ubuntu.
Download any version of tomcat you wish to install from apache tomcat official website.(.tar/.zip)
Extract the tomcat tar/zip file to any folder/directory in your linux pc.
Copy the extracted folder to /opt directory
directory looks like /opt/tomcat using cp command.
for e.g. sudo cp /Documents/apache-tomcat-8-0-24 /opt
This will copy my apache-tomcat-8-0-24 folder in Documents folder to /opt directory.
come back to /opt directory /opt
cd /opt
you are at /opt run following command
sudo chown -R username:username
for e.g. sudo chown -R akashgudadhe apache-tomcat-8-0-24
you are at /opt
ls -la
verify apache present or not
move to apache-tomcat-8-0-24 folder and bin directory inside it
/opt/apacheTomcatName/bin
you are now at /opt/apacheTomcatName/bin
run startup.sh file using following command you will see the message tomcat started.
for e.g. /opt/apacheTomcatName/bin/./startup.sh
This is optional step
tail -f logs/catalina.out
Open any web browser and type
localhost:8080 or type 127.0.0.1:8080
your tomcat installed successfully if not then mail me # gooddaysky1#gmail.com
It will become great pleasure for me if you send me your feedback about my answer # gooddaysky1#gmail.com ...!!!
Open Server.xml and find <Connector port="9090" protocol="HTTP/1.1" so that is your port number .
You have to write:
cd /opt/tomcat/bin
and after:
sudo bash startup.sh
and all well!!!
http://serverip:8080
NOTE: If you put the port 9090, then PLACED IN YOUR BROWSER http://serverip:9090