JRE not found on Ubuntu 20.04 - java

I tried to install java 11 on ubuntu 20.04 vps using this tutorial how to install java on ubuntu 20.04
But after installation and done setting $JAVA_HOME variable, I can't run a library because libjvm.so was not found.
Turns out jre not exist on $JAVA_HOME for all java version I installed (openjdk, oracle java). Why that happen and how to make jre installed?

Run the following code
$ sudo dpkg --purge "package-name"
Example
$ sudo dpkg --purge jdk-15.0.1
Then install JDK
And at last run the command
$ apt install -f

Related

Upgrading Java and Setting as Default on Raspberry Pi

I'm new to Raspberry-Pi & Linux and I wanted to code up a Minecraft server using PaperMC, but when I ran the server I got a warning saying that Java-11 would no longer be supported in future builds, so I thought it would be easy enough to upgrade to Java-16. I have not found documentation regarding this topic specifically which has led to using parts of differing tutorials, and I think I made a few mistakes. To start, I purged the old Java-11 version like so:
sudo -i
apt-get purge openjdk*
apt-get purge java11*
apt-get autoremove
Then I moved to the jvm directory and installed Java-16 from AdpotOpenJDK:
cd /usr/lib/jvm
wget https://github.com/AdoptOpenJDK/openjdk16-binaries/releases/download/jdk-16.0.1%2B9/OpenJDK16U-jre_aarch64_linux_hotspot_16.0.1_9.tar.gz
tar xzf OpenJDK16U-jre_aarch64_linux_hotspot_16.0.1_9.tar.gz
export PATH=$PWD/jdk-16.0.1+9-jre/bin:$PATH
java -version
openjdk version "16.0.1" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)
This export PATH command seems to be temporary, when I logout of sudo or exit the command window, and then check java -version again I get that the java command is not found. If I try setting JAVA_HOME & PATH:
export JAVA_HOME="/usr/lib/jvm/jdk-16.0.1+9-jre"
export PATH=$PATH:$JAVA_HOME/bin
The result is also temporary. Why can't I set this Java-16 as the default? Do I need to make a script that runs these commands on startup?
Here is a way to install it permanently using apt. Link to the information
https://paper.readthedocs.io/en/latest/java-update/index.html#debian-ubuntu
$ sudo apt update
$ sudo apt install apt-transport-https software-properties-common gnupg wget
$ wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
$ sudo add-apt-repository https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
$ sudo apt update
$ sudo apt install adoptopenjdk-16-hotspot

Installing OpenJDK 11 on Linux(Azure) using yum or wget

I want to install & configure openjdk 11 on Linux(vm in azure devops) either by yum or wget , i am new, not sure i tried using wget but openjdk 11 is not downloading
Need OpenJDK 11 to run Sonarqube
According to this post here: https://superuser.com/questions/1466580/unable-to-download-oracle-jdk-8-using-wget-command
"Following a licensing change of Oracle Java on 16 April 2019, Oracle now forbids anyone from downloading Java outside of their approved process.
That process is currently to log in to an Oracle account, accept the new license, then attempt the download with the authentication cookies in place."
In order to download it now you must use apt-get command if you use ubuntu or debian so on.
I know it says java 8 but this applies to all java versions
EDIT: I do not use centos so I cannot personally test this but try if this works
$ sudo yum install java-11-openjdk-devel
or
$ sudo yum install java-11-openjdk
You can try below scripts to install jdk 11 on azure linux vm.
sudo rpm --import http://repos.azul.com/azul-repo.key
sudo curl http://repos.azul.com/azure-only/zulu-azure.repo -o /etc/yum.repos.d/zulu-azure.repo
sudo yum -q -y update
sudo yum -q -y install zulu-11-azure-jdk
See here for more information.

How to uninstall jdk 12.0.1 from Mac OS?

I want to uninstall java version 12.0.1 on macbook pro.
I have installed java 12.0.1 but its not supported for my eclipse Kepler version..
I have tried by some commands in terminal but its all not workout.
Could anyone help me to uninstall Java 12 ?
By using this commands, can easily uninstall java from macOS.
java -version
sudo rm -rf /Library/Java/*
sudo rm -rf /Library/PreferencePanes/Java*
sudo rm -rf /Library/Internet\ Plug-Ins/Java*
Run java -version again to confirm if java was successfully uninstalled.

How to install the latest openjdk 12 on Ubuntu 18.04

I've installed the default jdk by issuing the command:
apt-get install default-jdk
This will install openjdk 11 and apt-get seems to install the files all over the place. Examples:
/etc/java-11-openjdk/management
/usr/lib/jvm/java-11-openjdk-amd64/lib
/usr/share/doc/openjdk-11-jre-headless/JAVA_HOME
/var/lib/dpkg/info/openjdk-11-jre:amd64.postinst
As you can see by the example locations above, there are files scattered everywhere.
I've just installed a web app that's giving a warning that it only supports jdk 12 (I think it's the latest openjdk version). How can I install version 12 so that it replaces version 11? What is the best way to upgrade the openjdk version on Ubuntu 18.04 so that it doesn't mingle with the previous version?
This works for me:
Download archive with wget or go to the JDK 12 GA Release site and download the archive manually:
wget https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz
Create the /usr/java directory:
sudo mkdir /usr/java
Move archive to the new directory:
mv openjdk-12.0.2_linux-x64_bin.tar.gz /usr/java
Go to this directory:
cd /usr/java
Unpack archive:
sudo tar -xzvf openjdk-12.0.2_linux-x64_bin.tar.gz
Set the environment variables, for this open the /etc/profile file:
sudo nano /etc/profile
And add the following code to the end of this file:
JAVA_HOME=/usr/java/jdk-12.0.2
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Configure Java commands to use the newly JDK by default:
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-12.0.2/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-12.0.2/bin/javac" 1
Check Java version:
java -version
If you previously had another version of Java installed and the version has not changed, try to run the following command and to select the desired version:
sudo update-alternatives --config java
The official package repository from Ubuntu doesn't provide a Openjdk12 package because openjdk11 is the last version of the openjdk package for your version.

Error While installing netbeans in ubuntu 12.04

I tried to install netbeans 'netbeans-7.2.1-ml-linux.sh' on my ubuntu12.04
But when i am executing this .sh file i am gettig the exception given below.
Configuring the installer...
Searching for JVM on the system...
Extracting installation data...
Running the installer wizard...
Can`t initialize UI
Running in headless mode
Exception: java.awt.HeadlessException thrown from the UncaughtExceptionHandler in thread "main"
You need to install Java Runtime Environment
sudo aptitude install default-jre
Refer to this answer:
netbeans installation error: can't initialize ui running in headless mode
Worked for me. For some reason, with OpenJDK the installer was unable to open a GUI.
The Problem is the support of openJDK for the UI.
The solution is installing Oracle JDK, open your terminal and write the following commands:
sudo apt-get remove openjdk*
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo apt-get install oracle-java7-set-default
after that reinstall netbeans.
You're missing a X-Server for installation (java.awt.HeadlessException). The installation script needs a UI.
For some reason the sh installer does not work with the openJDK 7.
Quick fix to install is to change back to JDK 6.
run:
sudo update-alternatives --config java
(select java 6)
sh netbeans-7.2.1-ml-linux.sh
the installer should run and then just switch back to the java 7 JDK with update-alternatives.
In my case, I had openjdk installed, where /usr/bin/java was point to the installed openjdk.
I solved it by installing the Oracle JDK 7, from a tar.gz file. Extract the tar ball to a location say your $HOME directory.
After that
I modified the .bashrc file and modified the PATH variable to
PATH=$HOME/jdk1.7/bin/:$PATH export PATH
Remember the path to your jdk/bin should be appended to PATH, as as result the system will find the java executable in your path rather than picking the installed openjdk.
Note: I chose not to uninstall installed openjdk, as most of my Libreoffice and other installed applications were depending on it.
First you have to update
sudo apt-get update
Then default java
sudo apt-get install -f default-jre
sudo apt-get install -f default-jdk
And should be done.
This is what fixed it for me:
I installed the Java JDK. In this case:
sudo aptitude install openjdk-8-jdk
Here's the kicker: I made sure that my Home and Path variables were set properly. Again, in my case:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin
My initial issue was not having the JDK installed. It was then not having the environment variables properly set. If they aren't properly set, the installer won't launch. Simple as that.

Categories

Resources