• Post Reply Bookmark Topic Watch Topic
  • New Topic

Variable JAVA_HOME issue in Windows 8.1  RSS feed

 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the instructions in "How can I create my first Java program?" for configuring a new System variable JAVA_HOME and then adding "%JAVA_HOME%\bin;" to the beginning of System Path, everything works great on my work laptop running Windows 7.
No issues, works as expected. Life is good.
However, not so on my personal laptop running Windows 8.1. I don't know if this is a Windows 8.1 issue, my particular configuration of my Windows 8.1, there is some other trick that I don't know, or user error. Darn users.
;-)
My symptoms are as follows:
Same process on Windows 8.1 that I did on Windows 7.
Configure a new System variable JAVA_HOME set to "C:\Program Files\Java\jdk1.8.0_11" and then add "%JAVA_HOME%\bin;" to the beginning of System Path as directed.
Open a new CLI and type "javac -version" and the correct version appears as expected.
Everything works fine until I reboot.
After rebooting "javac -version" returns the dreaded "'javac' is not recognized as an internal or external command . . . ".
"path" at the command line returns the current path, however, in the path displayed I do not see the character string
"C:\Program Files\Java\jdk1.8.0_11\bin", instead is see "%JAVA_HOME%\bin;".
If I open Environmental Variables and confirm that the variable named JAVA_HOME and Path are correct by viewing but not changing anything, not even clicking on <Edit>, then <OK> to exit, next time I open a new CLI "javac -version" works correctly and my "path" command correctly displays the actual path "C:\Program Files\Java\jdk1.8.0_11\bin;" at the beginning of my path as expected instead of "%JAVA_HOME%\bin;" .
This is reproducible every time.
My resolution was to delete the System variable JAVA_HOME and use "C:\Program Files\Java\jdk1.8.0_11\bin;" in the Path instead of "%JAVA_HOME%\bin;".
Am I doing something wrong?
Does this work correctly for others on Windows 8.1?
I'm OK with user error, but I cannot figure out what I need to do different in order to use the variable with the Path.

Thank you in advance for your time and experience.
Cheers,
Tim
 
Steve Kedzie
Greenhorn
Posts: 22
Mac Netbeans IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,

It looks like you are using \bin twice. If JAVA_HOME is already set to C:\Program Files\Java\jdk1.8.0_11\bin, then %JAVA_HOME% does not need the second \bin or vice-versa.

Steve
 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I wish it was that easy. From above:
Configure a new System variable JAVA_HOME set to "C:\Program Files\Java\jdk1.8.0_11" and then add "%JAVA_HOME%\bin;" to the beginning of System Path as directed.
And it works correctly after opening Environment Variables and closing. If it was a case of double bin it would never work.
Thanks for suggestion.
 
Steve Kedzie
Greenhorn
Posts: 22
Mac Netbeans IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I misread your original post. In this case then, I would follow through with your intention of not using JAVA_HOME, and just use the absolute path to your JDK in your $PATH env variable. I have a Windows 8 machine configured with JDK 8 and only have the absolute path to the JDK in my $PATH variable as well as a $CLASSPATH env variable set to the parent folder of all my Java projects. Everything is working fine so far and that includes Java EE with Glassfish as well.
 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the follow-up.
I will do that.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you should remove the classpath variable if it only contains your Java work folder.
The ordinary Java installation will work withoiut a JAVA_HOME but NetBeans requires it. At least I think NetBeans does.
 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I never modified my classpath to add any Java references within it.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the CLASSPATH was set up by other applications, add .; (dot‑semicolon) to its beginning.
 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Windows 8.1 laptop in question has no CLASSPATH variable configured for neither system nor user.
I'll add this tip to my personal knowledge base for future reference, may come in handy one day.
Thank you for your time and experience.
I appreciate it.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't have a CLASSPATH already set up, don't set one up now.
 
Tim Spreitzer
Greenhorn
Posts: 6
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK I won't.
Thank you.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!