This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes environment variable - correct setup is not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "environment variable - correct setup is not working" Watch "environment variable - correct setup is not working" New topic

environment variable - correct setup is not working

Andrew Baba

Joined: Nov 23, 2011
Posts: 20

I have changed Java environment variables good few times recently and I have never had problem like today. I have set up new Win 7 Proffesional 64-bit. I have installed JDK and I am stuck with variables.
Please have a look on pics. I also checked official oracle documentation for win7 and looks like I am doing everything OK.

1. Pic1 displays path on my hdd to my JDK

c:\program files\java\jdk1.7.0_03

2. Pic2 displays what I am going to edit

3. As a result still getting the same answer that javac is not recognised as an internal or external command.

Any ideas what am I doing wrong ?

I also tried to change name path using " ~ "sign to avoid empty spaces like C:\progra~1\... but this is not working either.
I tried close terminal, restart win, after each step.
I tried to change path to c:\program files\java\jdk1.7.0_03\bin

Is there any way to set this up through command line ?
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 123
You circle "JAVA_HOME" but then indicated you set the path. "JAVA_HOME" is frequently used by scripts, but does not work for a command line window. You want to make sure you are setting the "PATH" (path) environment variable to include the java bin directory. Take care not to delete or modify any of the current entries in the path variable or you may break something.

As a side comment, you do want to re-open the command line window when changing the path but you should not need to perform a restart of the entire system.
Andrew Baba

Joined: Nov 23, 2011
Posts: 20
Thank you very much. That's working now.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19783

JAVA_HOME should not include the bin folder. That should be part of the PATH, but not JAVA_HOME. My own PATH includes %JAVA_HOME%\bin so I only need to change JAVA_HOME and the PATH will be automatically updated as well.

How To Ask Questions How To Answer Questions
Brian Burress
Ranch Hand

Joined: Jun 30, 2003
Posts: 123

Good suggestion on the %JAVA_HOME% use in the path. Also, thanks for pointing out that JAVA_HOME should not have the bin dir. I focused on answering the question and overlooked that aspect!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14428

Also, the value of JAVA_HOME should not have a semi-colon ; at the end. Just the name of the directory: C:\Program Files\Java\jdk1.7.0_03

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
You also need to change the title of this thraed to environment variable - incorrect setup is not working

I agree. Here's the link:
subject: environment variable - correct setup is not working