DEV Community

loading...
Cover image for What to do if Java command is not recognized by  terminal.

What to do if Java command is not recognized by terminal.

rakibhasan455 profile image Md. Rakibul Hasan ・2 min read

Now a days we install java in our windows for our own work.But it's quite annoying while it's not recognized by the terminal.Sometimes we even run java file from terminal so it needs to be fixed.
So here is the thing that you can do.
Step 1:
First of all right click on this pc.
Alt Text
Step 2:
Go to properties and click advanced system settings.
Alt Text
Step 3:
Now click on environment variables.
Alt Text
Step 4:
Now look at user variables. Look if there is any path variable.
If there is path variable then look at Method 1..
If there is no path variable then look at Method 2..
Alt Text
Method 1:
in your case if there is path variable.You have to select path variable and click edit.
Alt Text
Now click on new . And paste the location of your java bin folder.
Alt Text
Click and copy the location.In my case it's location is:
C:\Program Files\Java\jdk-14.0.1\bin
Alt Text

Now click on ok .Then open the terminal.
write--> "Java -version".
Alt Text
it should show your java version.
If it's not then reinstall java by downloading java executable file from https://www.oracle.com/java/technologies/javase-downloads.html

Method 2
If there is no path variable then click on new.
Alt Text

write the variable name as "path" And paste the location of your java bin folder in variable value box.
Alt Text
Click and copy the location.In my case it's location is:
"C:\Program Files\Java\jdk-14.0.1\bin"

So i have wrote the variable name as "path" and pasted "C:\Program Files\Java\jdk-14.0.1\bin"
Alt Text

Now click on ok .Then open the terminal.
write--> "Java -version".
Alt Text
it should show your java version.
If it's not then reinstall java by downloading java executable file from https://www.oracle.com/java/technologies/javase-downloads.html

Hope it will help you. Thanks !

Discussion

pic
Editor guide