0

I am setting Environment Variable, Still OS cant recognise. Check this out you will get it.

https://www.dropbox.com/s/raqr4wbtoxxz0b8/1.JPG

I tried with Admin privileges also still same but when I enter

echo %java_home%

or

echo %jre_home%

It is showing path corretly. Why isnt javac command working.

Any Help will be appreciated.

5 Answers 5

4

You don't have javac in your path. Setting the JAVA_HOME and/or JRE_HOME environment variables (which aren't needed any more, for the most part) does nothing to the PATH which the command shell uses to find executables.

Put the relevant JDK bin directory in your PATH environment variable instead - and unless you actually need JRE_HOME and JAVA_HOME for some reason, I'd get rid of them. If you do need them, get rid of the "bin" part - it should just be the root JRE directory, e.g.

c:\Program Files\Java\jdk1.7.0_45
Sign up to request clarification or add additional context in comments.

4 Comments

I m running Tomcat Server but when I am starting Tomcat, its showing me error:The JRE_HOME environment variable is not defined correctl This environment variable is needed to run this program.
@Jax-L: You may need it for Tomcat - but you didn't mention Tomcat anywhere in your question. That comes under "for some reason" in my answer. And the value of the environment variable is inappropriate anyway - I've edited my answer to indicate that.
Thanx a lot! really appreciate your help! :) But I didnt get Why %PATH% is defined for javac. I mean how 'path' variable name is recognised by javac & not 'JAVA_HOME'. It gives same path? Can u post any link which explain this?
@Jax-L: The path is how the javac executable is found in the first place. It has nothing to do with Java specifically - it's just part of the command shell. If you'd written the full path to javac explicitly in the command shell, you wouldn't have seen that issue (but it would have been a pain).
2

Your path JAVA_HOME should be, for example

C:\Program Files\Java\jdk.1.7.0_45

And your Path variable should be

...;%JAVA_HOME%\bin

javac is in the bin folder which should be on your path.

Comments

2

That has nothing to do with Java environment variables.

When you type javac, or any other command, Windows will search the folders in the %PATH% environment variable to find an EXE file with that name.

You need to add your JDK directory to %PATH%.

You also need to restart cmd to pick up the changes.

2 Comments

Thank You. But Why Windows does find PATH variable for javac command?
@Jax-L: Because you never put it there.
0

Include the JRE/JDK path in System variables->PATH as well

After adding path varaibles,restart the cmd

Comments

0

You must restart cmd for new variables to be picked up. And java bin folder needs to be included in path. When you type javac it goes through all folders defined in path to find it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.