No suitable Java Virtual Machine could be found on your system - java

I am running Ubuntu 16 on my computer and
I am attempting to run a Java application on my computer and I get the following error:
No suitable Java Virtual Machine could be found on your system.
The version of the JVM must be at least 11.
Please define INSTALL4J_JAVA_HOME to point to a suitable JVM.
However I have already Java installed and a virtual machine.
When I press
$java -version
I get the following output:
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (Zulu 8.33.0.1-linux64) (build 1.8.0_192-b01)
OpenJDK 64-Bit Server VM (Zulu 8.33.0.1-linux64) (build 25.192-b01, mixed mode)
Does anyone know how I can fix this problem? Many thanks.

Compare
The version of the JVM must be at least 11
and
openjdk version "1.8.0_192"
(i.e. Java 8)
Upgrade your Java version.

From the output above, it is evident that an updated version of Java is missing. You need at least a version of JVM equal to 11 or upper.
Let’s now proceed and install both JRE and JDK which both constitute JAVA
JRE
Ubuntu
sudo apt install default-jre
Arch
sudo pacman -S jre-openjdk
JDK
Ubuntu
sudo apt install default-jdk
Arch
sudo pacman -sS java | grep jdk
sudo pacman -S jdk-openjdk
you can check the version with java -version
java -version

Related

macOS tells me Java version is 11 but I just installed version 19 with Homebrew

I a M1 macOS, I am trying to install Java 18-19, so I do as suggested in How to brew install java? :
brew install java
After many downloadings, I receive the following message:
Warning: openjdk 19.0.1 is already installed and up-to-date.
To reinstall 19.0.1, run:
brew reinstall openjdk
So I do this reinstallation and everything seems OK.
I would think that Java (version 19.0.1) is already installed, but if I check it as suggested at How to brew install java? :
java --version
Then I get:
openjdk 11.0.18 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.18.10.1 (build 11.0.18+10-LTS, mixed mode)
How can I solve this and get the right version?
It could be the case that the error is really simple, but I really do not know how to solve it. I referred to How to brew install java? because it seems it helped a lot of users. I also tried java -version shows earlier version but java 11 is already installed and java -version shows earlier version but java 11 is already installed, but for both of them (which have the same solution) zsh tells me the command does not exist.
(EDIT) Trying to reinstall openjdk
(base) name % brew reinstall openjdk
==> Fetching openjdk
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/manifests/19.0.1-1
Already downloaded: /Users/name/Library/Caches/Homebrew/downloads/c7246ceb366faabcf9dd032058533f2e54a55b52e0baf1e45630280826b0f013--openjdk-19.0.1-1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/blobs/sha256:8380eef4472205fdc0b3968c1241bfc616efaea90aef325198d767a74d2f78ee
Already downloaded: /Users/name/Library/Caches/Homebrew/downloads/f3ccacbd4108895428c5d98052e634e0bb296638d180f9fffe8018c6ef76823c--openjdk--19.0.1.monterey.bottle.1.tar.gz
==> Reinstalling openjdk
==> Pouring openjdk--19.0.1.monterey.bottle.1.tar.gz
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
openjdk is keg-only, which means it was not symlinked into /usr/local,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
If you need to have openjdk first in your PATH, run:
echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc
For compilers to find openjdk you may need to set:
export CPPFLAGS="-I/usr/local/opt/openjdk/include"
==> Summary
🍺 /usr/local/Cellar/openjdk/19.0.1: 638 files, 318.6MB
==> Running `brew cleanup openjdk`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Windows WSL Ubuntu 22 doesn't recognise the upgraded Java version I installed on Windows

I'm a newbie and am confused over the setup for one of my cs courses.
I originally have Java 8 in both Windows and Ubuntu, but then I realised that I need to use jshell for testing in Ubuntu as well, which is only available for Java 9 and higher.
Hence I downloaded the newest Java 19 on my windows but Ubuntu doesn't recognise it and still use Java 8.
How can I go around to update the Java in Ubuntu as well without having to redownload it again?
Below is on my Ubuntu terminal:
hejin#LAPTOP-8I6A5M2K:~/cs2030s$ java.exe -version
java version "1.8.0_351"
Java(TM) SE Runtime Environment (build 1.8.0_351-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)
hejin#LAPTOP-8I6A5M2K:~/cs2030s$ javac.exe -version
javac 1.8.0_351
hejin#LAPTOP-8I6A5M2K:~/cs2030s$ jshell.exe
jshell.exe: command not found
hejin#LAPTOP-8I6A5M2K:~/cs2030s$ jshell
Command 'jshell' not found, but can be installed with:
sudo apt install openjdk-11-jdk-headless # version 11.0.17+8-1ubuntu2~22.04, or
sudo apt install openjdk-17-jdk-headless # version 17.0.5+8-2ubuntu1~22.04
sudo apt install openjdk-18-jdk-headless # version 18.0.2+9-2~22.04
sudo apt install openjdk-19-jdk-headless # version 19.0.1+10-1ubuntu1~22.04
(to be honest I don't know why it seems others can do fine with just java Hello.txt and javac Hello.txt but I have to add .exe at the back.
And below is my command prompt terminal:
C:\Users\User>java -version
java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
C:\Users\User>javac -version
javac 19.0.1
C:\Users\User>jshell -version
jshell 19.0.1
C:\Users\User>jshell
| Welcome to JShell -- Version 19.0.1
| For an introduction type: /help intro
jshell> 1 + 1
$1 ==> 2
jshell>
I am confused over what some answers I searched online talked about changing the environment variable path as well... When I checked the advanced system settings the jdk19 path seems already there.
screenshot of my system settings environment variables
Here are a few things to check with your path dealings Windows -> WSL Ubuntu. On Windows you can confirm where java is found by:
echo %Path%
=> should print list of colon separated folders on your path example:
C:\java\jdk-20\bin;etc
which java.exe
=> should print name of java.exe found inside %Path% example:
C:\java\jdk-20\bin\java.exe
When you run wsl.exe to load WSL Linux distribution the Windows Path is translated to Linux semi-colon separated PATH without drive letters:
C:\java\jdk-20\bin;etc => /mnt/c/linux/jdk-20/bin:etc
On WSL Linux check where it looks up PATH:
echo $PATH
=> should print list of colon separated folders on your path:
/mnt/c/linux/jdk-20/bin:etc
=> its likely you have 2 JDK in Linux PATH
which java.exe
=> finds "java.exe" of the first JDK in the Linux PATH
Have a look at any WSL Ubuntu bash profiles which may also override PATH in WSL to see what causes the 2nd JDK in path - typically ~/.bashrc or ~/.profile and fix so the later JDK19 is first or only JDK one resolved.
Note that fixing WSL Linux to access Windows JDK introduces a new issue if you actually need Linux JDK, but you could always use "java" vs "java.exe" from WSL if you need to work in both JDK platforms from Linux.

Update Java version in Windows 10 WSL

I had openjdk 11.0.2 installed. I upgraded the java version by running
sudo apt update
sudo apt install openjdk-11-jdk
If I run sudo apt install openjdk-11-jdk again, it shows a message saying that "openjdk-11-jdk is already the newest version (11.0.11+9-0ubuntu2~20.04)"
However, when I do java -version it displays the older version 11.0.2 not 11.0.11
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
The JAVA_HOME still shows "/opt/java/jdk-11.0.2", so I guess this might be the problem that the java -version is still showing the older version?
When I do whereis java it shows
java: /usr/bin/java /usr/share/java /opt/java/jdk-11.0.2/bin/java /mnt/c/Program Files/Common Files/Oracle/Java/javapath_target_917640/java.exe /usr/share/man/man1/java.1.gz
Not sure where the newest version was installed so that I can make the JAVA_HOME point to that one
openjdk-11-jdk-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb and openjdk-11-jre-headless_11.0.11+9-0ubuntu2~20.04_amd64.deb package shows (by extracting with 7-zip) that OpenJDK 11 will be installed at /usr/lib/jvm/java-11-openjdk-amd64.
This will give you enough information about appending environment variables such as PATH and JAVA_PATH.
And, there may be a path called default-jvm or so, you may use that path accordingly.

How to change the default JRE in tomcat through parellel plesk

I have a parallel plesk console. Tomcat version istalled is 7. and JRE also 1.7. But some application is not working. So i need to change JRE 7 to JRE 8.
How it is possible through plesk console?
you need to uninstall JDK 7 and re-install JDK8.
for uninstalling java you can refer below links :
http://www.2daygeek.com/remove-uninstall-oracle-java-openjdk-on-ubuntu-centos-debian-fedora-mint-rhel-opensuse/#
https://askubuntu.com/questions/84483/how-to-completely-uninstall-java
Install JAVA 8
First of all, you need to add webupd8team Java PPA repository in your system. After that install, Oracle Java 8 using following a set of commands.
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Verify Installed Java Version
After successfully installing Oracle Java using above step verify installed version using the following command.
mayank#tecadmin:~$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Configuring Java Environment
Also, install Java configuration package. It seems like below package is already installed with latest operating systems during installation of JAVA packages. But you can still make sure by running below command.
$ sudo apt-get install oracle-java8-set-default
Now edit /etc/environment configuration file and add following entries to set JAVA_HOME and JRE_HOME environment variables.
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre

Not able to run java desktop application on Mac OS X Yosemite (10.10)

I have a requirement where I have to run java application(.mpkg) with latest JRE version on Mac OS X Yosemite 10.10. And I have done the following steps.
I have installed the latest JRE from Oracle website.
Set the JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/ in ~./bash_profile and also ran shell command source ~./bash_profile
echo $JAVA_HOME is showing /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/
Java -version is providing output
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
But when I am running the .mpkg/installer I am getting exception pop up saying "To view this web content, you need to install the Java Runtime Environment."
Please suggest answers specific to the JRE.
Little background: Earlier, I had JDK1.6 installed on my Mac OS X Yosemite 10.10 machine. I had to uninstall it because I have to run my application with latest version of JRE. I uninstalled JDK1.6 by following steps:
sudo rm -rf /System/Library/Java/JavaVirtualMachines/1.6.*
sudo rm -rf /Library/Java/JavaVirtualMachine/1.6*
sudo unlink /System/Library/Frameworks/JavaFrameEmbedding.framework/Versions/CurrentJdk
Note: The below points should be read keeping into mind that they are tested with Mac OS X 10.10.2 and Java 7 & 8.
I have observed the behavior of the installations of the JDK/JRE for Java 7 & 8 on Mac OS X 10.10(assuming this should go well with Mac OS X 10.7.3 and later, when Mac OS started supporting java 7 and later).
On a Mac machine, either JRE 7 or JRE 8 can be installed into the default location which is /Library/Internet Plug Ins/JavaAppletPlugin.plugin/.
As we upgrade from JRE 7 to JRE 8, the earlier version gets overridden from the system.
The command java -version wouldn't show any thing until you have installed JDK.
We can have two or more versions of JDK on the same system. They can be found from directory /Library/Java/JavaVirtualMachines/.
By default, the command java -version would always show the latest JDK installer on the system.
As we remove or upgrade the JDK from the system, java -version command shows the results accordingly.
As per my requirements, I never had to set the JAVA_HOME. As I stated above that JRE can be found from the path /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/ and in postscript I initiated my application using command /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
This way, we don't to remove the JDK1.6 from our system. Rather, if we are running our application with just java then make sure correct version of JDK is installed but if we are running our application using the JRE then make sure you provide the full path of the JRE /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

Categories

Resources