Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Problem getting version of Java in PowerShell in windows.

I have downloaded a JDK for my system and opened the powershell. When I try the command 'java - version' I receive this error...

PS C:\Users\LCrum> 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 -version
  • ~~~~
    • CategoryInfo : ObjectNotFound: (Java:String) [], CommandNotF oundException
    • FullyQualifiedErrorId : CommandNotFoundException

Can someone help.?

2 Answers

saykin
saykin
9,835 Points

Have you defined your windows environment variable to include Java?

If you are using Win 10, try this:

  1. Click start and type in Environment Variables and click it when it pops up. You can also open the command line by pressing WIN + R and paste in this rundll32.exe sysdm.cpl,EditEnvironmentVariables.

  2. Once the Environment variables window pops up, click on path and click on edit.

  3. Check to see if the Java directory is there, if not, click on New and find the Java\jdk-<version>\bin folder and add it. Ok out of all the menu.

  4. Restart powershell and run 'java -version' again.

Fab! Thank you saykin!