Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java --version doesn't work in the command line

Tags:

java

jvm

I tried java --version in the command line and I get :

Unrecognized option: --version Error: Could not create the Java virtual machine Error: A fatal exception has occurred. Program will exit. 

Everything was working fine until I installed jre 7 (I had jdk 1.6 preinstalled ) So, I uninstalled the previous versions, restarted and then installed fresh jdk 7u5 windows i586.

Still I get the same problem. Can anyone help me with this?
I am unable to install and run maven for this reason.

like image 662
Deepak behera Avatar asked Jul 18 '12 23:07

Deepak behera


People also ask

Why is my Java not working on Command Prompt?

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.

Why is Java not recognized?

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.


2 Answers

You used two - marks. Try with one: java -version.

Update: Since Java 9 java and javac commands support both --version and -version.

like image 67
Pshemo Avatar answered Sep 28 '22 02:09

Pshemo


java -version 

This is the command to get the current installed version info

like image 39
Anuj Avatar answered Sep 28 '22 03:09

Anuj