GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes Java\bin PATH setup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java\bin PATH setup" Watch "Java\bin PATH setup" New topic
Author

Java\bin PATH setup

Grant Kohl
Greenhorn

Joined: Jan 30, 2011
Posts: 4
Hola!~

I carefully read the instructions on the "How to create your first Java Program" page, and I seem to have everything setup correctly. However, I'm unable to pull up the Java version when I go into command prompt and type: 'javac -version' (hence, I'm thinking I jacked this up). Here's a brief recap of what I've done:

I went to the oracle page, and downloaded/installed a recent version of JDK: JDK 6 Update 23 with JavaFX 1.3.1 SDK

I went into environment variables, created a new variable under system variables named: JAVA_HOME and set the path as: C:\Program Files (x86)\Java\jdk1.6.0_23\bin

I then clicked on edit for the path variable under system variables, and I deleted two java paths that were inserted in there upon installation. One had something to do with an emulator for JavaFX, and the other one was a link to the \bin for JavaFX. Was I wrong in doing that?

I then added in the entry: %JAVA_HOME%\bin; at the forefront and clicked on ok. After that, I went to command prompt, typed in javac -version and I got an "javac is not recognized message"

Any help would be much appreciated!

Grant
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
Welcome to the Ranch

Did you open a new command prompt window? The new path is only recognised by a new command line.
Joydeep Ghatak
Ranch Hand

Joined: Sep 30, 2009
Posts: 41

Also, please try the following,

1. Put the path as: C:\Program Files (x86)\Java\jdk1.6.0_23\bin; [ I mean where the JDK has been installed successfully] at the beginning of the PATH environment variable, instead of using through JAVA_HOME, initailly

2. Then as 'Ritchie' suggested, open a new command prompt window to check the 'java' and 'javac' command.

3. Also please check the 'Java' version that you have downloaded is 32 bit or 64 bit, and what is the architecture of your machine.

4. Also please make sure that you have downloaded and installed JDK and not JRE only.

5. Once above steps are successful, use JAVA_HOME as per standard usage.

Thanks,
Joydeep


“Men are only as good as their technical development allows them to be.”
Grant Kohl
Greenhorn

Joined: Jan 30, 2011
Posts: 4
First off, thanks for the help! I certainly appreciate it!

I uninstalled anything related to Java/Oracle and reinstalled the 64 bit version of jdk1.6.0_23 because I'm running Windows 7 64 bit.

1. I put the path in as C:\Program Files\Java\jdk1.6.0_23\bin, deleted the JAVA_HOME variable I had created earlier, opened a new command prompt, and the javac -version command actually worked!

2. I tried opening a new command prompt prior to uninstalling JDK and it still didn't work unfortunately

3. After reinstalling, I can say with full confidence that I'm using the 64 bit version of jdk1.6.0_23

4. I've definitely got both installed, but this begs the question: Should I uninstall and reinstall the 32 bit version of JDK? If I'm using a 64 bit JDK, will the programs I create not work with the 32 bit version of JRE, or how does that work?

5. I reset all the environment variables the way they should be (with JAVA_HOME having the same path I used in PATH, and PATH having %JAVA_HOME%\bin) and the javac -version command stopped working again :/ Any idea why?

Grant
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
There should be no difference in the code which you run on the 64 bit version from the 32 bit version.
Does your JAVA_HOME variable end with \ ? Or \bin?
Grant Kohl
Greenhorn

Joined: Jan 30, 2011
Posts: 4
It ends with \bin: C:\Program Files\Java\jdk1.6.0_23\bin

That's right, right?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3833

Grant Kohl wrote:It ends with \bin: C:\Program Files\Java\jdk1.6.0_23\bin

JAVA_HOME should point to your JDK installation directory, in this case C:\Program Files\Java\jdk1.6.0_23


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Joydeep Ghatak
Ranch Hand

Joined: Sep 30, 2009
Posts: 41

Hi Grant,

As correctly pointed out by 'Ritchie', you will not face any issue with the 32 bit or 64 bit java version in normal programs.
But when you will try to use Eclipse or similar IDE later on, those tools, takes care of the 32 bit or 64 bit default java installation path. ( For now you can ignore this)

Now as with the java path in PATH env variables works fine, you can try to create JAVA_HOME under 'System Variables' and provide the %JAVA_HOME%\bin; in PATH variable and add this thing as the first value in the PATH variable.

e.g JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_23 [OR the exact JDK path where java is installed]
PATH=%JAVA_HOME%\bin;

NOTE ::

1. Please make sure that both PATH and JAVA_HOME is under 'System Variables' section.
2. Please make sure JAVA_HOME value SHOULD NOT end with any semicolon (;) or colon( : ) or slash ( / or \ )

Thanks,
Joydeep
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39084
    
  23
If your JAVA_HOME ends bin, then your PATH will end bin\bin, which doesn't exist. You get no error messages if you include a non-existent directory in your PATH; it simply doesn't work.
Grant Kohl
Greenhorn

Joined: Jan 30, 2011
Posts: 4
Ahhh, I can't believe I didn't notice that. JAVA_HOME fills in for the path, and it's almost common sense that you wouldn't have \bin in there (since it goes into the path variable next to \bin: %JAVA_HOME%\bin)

It works good now, thanks for the help!

 
GeeCON Prague 2014
 
subject: Java\bin PATH setup