Oracle Java is required by some applications to run. Let's replace OpenJDK with Oracle JRE on Ubuntu to be able to run STM32CubeProgrammer, JabRef and others
Java is a cross-platform development platform used by many applications. If you want to run Java based applications, you must install a runtime. Java is developed by Oracle. There are two packages: JDK (Java Development Kit) and JRE (Java Runtime Environment). While the first is needed to develop Java applications, for running them you need the runtime.
Due to licensing, on Linux you have the possibility to install only OpenJDK from software repositories. That is an open source GPL licensed JDK edition. Well, I had this one installed (package openjdk-8-jre) on Ubuntu and I was facing some problems. JabRef, a references manager application, wouldn't run. Initially I thought there is something wrong with the current release. Later I installed (the GUI installer worked) STM32CubeProgrammer, a programming utility for STM32 microcontrollers. Neither this one would launch.
Java Runtime Download page for Linux
The error message when attempting to launch the application from terminal wasn't useful, claiming it can't find the main class of the application.
Error: Could not find or load main class com.st.app.Main Error: Could not find or load main class org.jabref.JabRefMain
Some suggested on the ST forum that openjfx package needs to be installed. Did that. Nothing changed. Next thing to try is to install Java from Oracle.
At the time of writing this, the latest JRE is at version 8, while the latest JDK is at version 13. JDK includes JRE, however JDK 13 does not include javaws executable. With JDK 13, I wasn't able to launch either of those two above mentioned applications. So, download the latest JRE for Linux. Not the JDK. Select the appropriate version for your system architecture (32 or 64-bit). Don't choose RPM package. You will get a .tar.gz archive.
By default, it should download in the Downloads folder. I have Open a terminal and move to the folder where it is downloaded. Make a system folder and copy this archive in it. Extract this archive.
sudo mkdir -p /usr/local/java sudo mv -r jre-8u231-linux-x64.tar.gz /usr/local/java/ cd /usr/local/java sudo tar xvzf jre-8u231-linux-x64.tar.gz ls
The last command (ls) will display the contents of the folder. Copy the exact name of the extracted folder (which is jre1.8.0_231 in my example).
jre1.8.0_231 jre-8u231-linux-x64.tar.gz
It's time to remove any OpenJDK packages before proceeding.
sudo apt purge openjdk-\*
Java is extracted in a folder, but we have to let the applications know it is there. Create the system available Java executables (update paths as needed):
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre1.8.0_231/bin/java" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre1.8.0_231/bin/javaws" 1
At this point, Java applications should run. It is recommended to add it to path environment variable and set font rendering to display text with antialiasing. It can be done by editing .bashrc for the current user gedit ~/.bashrc or system wide sudo -H gedit /etc/bash.bashrc. Copy the following lines at the end of the file:
JAVA_HOME=/usr/local/java/jre1.8.0_231 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd' export _JAVA_OPTIONS
Don't forget to adjust paths if needed (in case you use a newer version of JRE). Restart computer or at least log out and then back in to reload environment variables. This post is based on remove-openjdk-and-install-oracle-jdk on ubuntu from flicsDB.
________________
* Oracle and Java are registered trademarks of Oracle and/or its affiliates. Linux is a registered trademark of Linus Torvalds. Other names may be trademarks of their respective owners.
What's wrong with linuxuprising/java ppa?
ReplyDelete```
add-apt-repository ppa:linuxuprising/java
apt-get install oracle-java11-installer-local
```