Home > database >  Why can't I run commands like 'java' from the Visual Studio Code terminal?
Why can't I run commands like 'java' from the Visual Studio Code terminal?

Time:04-04

I'm using Visual Studio Code's terminal (on a Windows 11 device) and can't run commands like java, flutter etc., be it VS Code's Powershell terminal or VS Code's Command Prompt terminal.

When I try to run java by typing java in the VS Code Powershell terminal, it displays:

PS C:\users\user> java
java : The term 'java' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
  java
  ~~~~
      CategoryInfo          : ObjectNotFound: (java:String) [], CommandNotFoundException
      FullyQualifiedErrorId : CommandNotFoundException

When I try to run java by typing java in the VS Code Command Prompt terminal, it displays:

C:\users\user> java
'java' is not recognized as an internal or external command,
operable program or batch file.

I can run java and flutter fine from the regular Windows Command Prompt (their bin folders are in the Path environment variables).

How do I allow these commands to be run in the VS Code terminal?

I've tried uninstalling and reinstalling VS Code, thinking I would be able to then run the commands, but I get the same problem.

I'm already able to run a java program using the "Run java" button in the top-right of the window. However, I want to be able to run java by entering the command in the VS Code terminal, similarly to running commands in Command Prompt.

I already have the "Extension Pack for Java extension" and "Dart" extensions for VS Code.

CodePudding user response:

make sure to download java extension ,

  • go to vs code
  • click "extensions" button on left side
  • after that, on search bar appeared on top left
  • search "java" and click the first result (will be extension pack for java)
  • and click "install" to download java extension and follow the instructions given below in "details" option

then after installing, you have to install some complier stuff from google

if you face problem, click this link below

https://youtu.be/ClU9N4ub_Ko

  • this will give you idea

  • hope it helps you

  • for flutter in vs code

  • click "extensions" button on left side

  • after that, on search bar appeared on top left

  • search "dart" and click the first result (dart)

  • and click "install" to download dart extension and follow the instructions given below in "details" option

then after installing, you have to install some complier stuff from google

CodePudding user response:

I think you are running java using direct run button do using java "run java" the button on side and check if its working.

enter image description here

  • Related