• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Java\bin PATH setup

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 76854
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Did you open a new command prompt window? The new path is only recognised by a new command line.
 
Ranch Hand
Posts: 43
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Grant Kohl
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 76854
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It ends with \bin: C:\Program Files\Java\jdk1.6.0_23\bin

That's right, right?
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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

 
Joydeep Ghatak
Ranch Hand
Posts: 43
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 76854
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
reply
    Bookmark Topic Watch Topic
  • New Topic