I got a MacBook Air M2 to develop Flutter applications. When I opened a project for the very first time, it asks me to install gradle extensions, but now when I open a project, Visual Studio Code shows me:
No Java executable found, please consider to configure your 'java.jdt.ls.java.home' setting or set JAVA_HOME in your path or put a Java executable in your path.
I tried to use java --version
to see if I had java in my machine. The command show:
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
But if I use the next command: which java
, it shows /usr/bin/java
. So, Can I consider that I have at least one java version?
What should I do? Do I need configure the current java in my machine as a default or install a new java? Could be problems if I install a new version since I already have one installed?
What should I do?
Delete whatever JDKs you already downloaded and installed.
Install SDKMAN!. This clever collection of shell scripts makes easy work of installing software kits such as a JDK.
At the console such as Terminal.app, execute:
sdk list java
From the list of JDK products known to SDKMAN!, choose which version of which product you want. Be sure to choose a vendor and product whose legal terms you find agreeable.
Copy the exact name of your choice. Type Q
to quit the list.
Then paste the copied name into the following line of your console, and execute.
sdk install java paste-product-name-here
Wait a few minutes as your desired JDK product downloads and installed.
Eventually SDKMAN! prompts you to ask if you want to make this JDK the default. Answer Y
for “yes”.
✔️ Easy-peasy, done.
Verify by doing these two tasks:
sdk list java
You should see an indicator of which JDK product(s) you have installed.
java --version
You should get a report of the default JDK product’s version number.
SDKMAN! can just as easily:
See the website for easy instructions.