Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run Java from the Windows PowerShell command prompt

I have Java installed on my machine (the JRE is under C:\Program Files\Java) but I can't run any java command from the Windows PowerShell command prompt.

>>> java -version
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

However, I have noticed that Java does work and that I can run Java commands on the old Windows command prompt. Turns out it's only PowerShell where I can't run those commands.

I have JRE 7 and I'm using Windows PowerShell on Windows 8.

like image 366
snakile Avatar asked May 29 '13 10:05

snakile


People also ask

Why Java is not working in command prompt?

The Java is not recognized as an internal or external command in Command Prompt error occurs if the environment variables are not configured correctly. By adding the correct path to an environment variable, you can resolve the issue. If the error persists, try installing the compatible Java version.

Can you run Java from command line?

While there are many IDEs with built-in execution capabilities (Eclipse and IntelliJ for example), Java can also be run directly from the command line.


1 Answers

Add it to C:/Program Files/Java/jre7/bin added to the classpath environment variable.

like image 168
Gyan Avatar answered Sep 18 '22 06:09

Gyan