0

I recently tried running java on debian 10 buster linux. I installed the default-jre and openjdk-11-jdk using the sudo command in the terminal. I confirmed the installations by running the command "sudo apt search openjdk" and it was installed. But when I try to verify the "java version" an error message could not create the Java Virtual Machine

How do I go about the process or what am I missing out to run java? Thanks

Wizking
  • 33
  • 6
  • What happens when you use `java -version` or `java --version` instead? – Mark Rotteveel Nov 17 '21 at 12:57
  • Does it say anything else apart from *"could not create the Java Virtual Machine"*? – Stephen C Nov 17 '21 at 13:29
  • @Stephen C yes it does. "A fatal exception has occurred. Program will exit." The above display on a new line after "could not create Java Virtual Machine" error message – Wizking Nov 17 '21 at 13:50
  • @Mark Rotteveel the second option "java --version" worked. – Wizking Nov 17 '21 at 13:53
  • OK ... so it is odd that `java version` says that. On my machine (Ubuntu Focal, OpenJDK Java 11 or 17) running `java version` says `Error: Could not find or load main class version` `Caused by: java.lang.ClassNotFoundException: version`. Anyway, you have your answer. Java is installed correctly. You were just running `java` with an incorrect command line option. – Stephen C Nov 17 '21 at 14:24
  • @Stephen C thanks so much. Funny both commands "java version" & "java --version" now works. I still don't know what I omitted or added initially. – Wizking Nov 17 '21 at 18:14
  • I solved the problem by closing the console and opening a new console. Strange behavior but it works now. Here running java 8 with Zorin 16 (Ubuntu 20.04) – remat_br Oct 07 '22 at 19:36

0 Answers0