Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"java -version" not working in command prompt

Tags:

java

grails

I downloaded this Java JDK and installed it.

But when I go to the command prompt to check the version, it says it's not recognized.

Is anyone else experiencing this issue with the latest Java?

I might not have installed the right version. I need the java that works with grails

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

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

C:\>

when i do a search on my computer for java, it does not find anything

like image 352
Alex Gordon Avatar asked Mar 04 '10 15:03

Alex Gordon


People also ask

Why is Java not working on CMD?

when trying to run the java command, this means that there is no java command on your shell's command search path. The cause could be: you don't have a Java JRE or JDK installed at all, you have not updated the PATH environment variable (correctly) in your shell initialization file, or.

How do I update Java from Command Prompt?

Right-click Command Prompt in the Programs list. In the Java Control Panel, click on the Update tab. Change the update notification settings as you desire.

How can I tell if Java is working using CMD?

Going to a command line and typing java -version can tell us for sure if Java is installed.


2 Answers

Windows 2k8 R2 server- For both java [-option] or %JAVA_HOME% to work in the command line you need the following:

In Control Panel->System and Security->System->Advanced system setting->Advanced->Environment Variables->System Variables

Edit the Path variable and add a ";" after the last value and add the the path to the Java bin directory: e.g.- C:\Progra~2\Java\jre6\bin\

Add the JAVA_HOME Variable with the value set to the path for the java executable: e.g.- C:\Progra~2\Java\jre6\bin\java.exe

like image 74
user2730936 Avatar answered Sep 21 '22 09:09

user2730936


Press simultaneously the "windows" and "pause" buttons on your keyboard, this will bring up the System Preferences dialog. In the Advanced tab, find Environment Variables.

Then, in the User (upper) section, create or update the following two variables :

  • JAVA_HOME = where you put your JDK, eg. C:/Java/SDK
  • PATH = %JAVA_HOME%/bin

Close the dialogs.

Then, in a new command-line console, try "javac -version" and see if it's detected. It's important that you use a new console, because environment variables are read only when the console is launched.

like image 21
Olivier Croisier Avatar answered Sep 19 '22 09:09

Olivier Croisier