Java command isn't working

I have a M1 macbook, I am working on my java project,
when I run
Code Block
$ which java

The output was

Code Block
/usr/bin/java


But when I try to get the version using

Code Block
$ java --version

then this was the output
Code Block
The operation couldn’t be completed. Unable to locate a Java Runtime.
Code Block
Please visit http://www.java.com for information on installing Java.

I verified that the system also has javac at /usr/bin/javac
I am unable to run the java file to compile

Thanks


Apple hasn’t supported its own flavour of Java for a long time, meaning that you’ll need to use a third-party Java setup (the obvious choice being the one from java.com). If you need help with your third-party Java setup, your best option is to escalate that via the vendor’s support channel.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Java command isn't working
 
 
Q