• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with set up for Head First Java  RSS feed

 
Joe Dixon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just picked up a copy of HSJ and downloaded the latest version of the java development kit (JDK 1.8.0_112).

I tried to set the correct path by following the instructions on this forum, but I think Java was installed to the wrong place, so it didn't seem to work. The java - version test in the command line returned what it was meant to, but the javac -version test did not.

I followed the instructions in this post.

Specifically, I tried the following:

Knute Snortum wrote:
Java and Javac are different do they need to be matching? 

They do.  Can you get to a command line and type

where java

I suspect you will get two entries in return, something like this:

The path that has "jdk1.8.0_112" in it is the one you want.  This means the other path (in this case, "C:\ProgramData\Oracle\Java\javapath") needs to be removed from your PATH environment variable.


Now, when I run where java, I get the following response:



I don't really know what I've done, or what I've done wrong.

Any help would be greatly appreciated.

Thanks.
 
Stefan Evans
Bartender
Posts: 1837
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe, welcome to the ranch

Sounds like you need to add the java directory to your "path" so that your computer can find it.
However it is funny that typing "java -version" gets you something while "where java" does not.

How about "javac -version" and "where javac" ?


I'm going to presume you are on windows
Can you find the directory where you installed the JDK to?

What do you get when you type "set path" at the command line?

 
Joe Dixon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stefan,

I'm running Windows 7, 64 bit.

I don't remember where Java installed to, but I moved it so it's in the top C: directory, since that's where most other people's seemed to be and it made sense to try and copy that.

Here's what my terminal looks like after trying each of the things you suggested:

C:\Windows\System32>java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

C:\Windows\System32>set path
Path=C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%;C:\ProgramData\Oracle\Java\
javapath\java;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows
\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\
Program Files (x86)\Skype\Phone\;%USERPROFILE%\.dnx\bin;C:\Program Files\Microso
ft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

C:\Windows\System32>where javac
INFO: Could not find files for the given pattern(s).

C:\Windows\System32>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>

Here's what my "Path" line looks like from the Advanced Environment Variables tab (for System variables).

C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%;C:\ProgramData\Oracle\Java\javapath\java;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Skype\Phone\;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\

Under user variables, I set up the following:
Variable name: JAVA_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_111\bin

 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%;...

Under user variables, I set up the following:
Variable name: JAVA_HOME
Variable value: C:\Program Files\Java\jdk1.8.0_111\bin 

You're very close.  First, JAVA_HOME should be set to the actual home of Java, so

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_111  (That's not an actual command, just a way of seeing what the value of JAVA_HOME is.)

Except, I think you have 112, not 111, so

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_112

You can confirm this by going into File Explorer and seeing it that folder exists.  Next, you need to adjust the PATH variable:

C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin;...

Remember to exit any command windows and restart them before you try your java -version and javac -version commands.

 
Joe Dixon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Thanks for your help. I've tried your suggestions, but haven't had any success.

Here's my command prompt:

C:\Windows\System32>java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

C:\Windows\System32>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\System32>



I really don't know how to fix this, and I'd be grateful of any help! :-)
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What part of my instructions above didn't you understand?  What problems did you run into? 

When you type:
 echo %JAVA_HOME%
what displays?  When you type
 path
what displays?
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you install a JDK or a JRE? You need the JDK; the JRE doesn't include javac. Why are you going into the System32 folder? You shouldn't have any of your own code there.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does JAVA_HOME contain? You are supposed to use JAVA_HOME\bin.
 
Joe Dixon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Thanks for the suggestions.

Campbell, I moved the Java file into C:\Program Files. I did have a copy of JRE, which I've now deleted. But I also have jdk1.8.0_112 in the Java file. And I changed the value of JAVA_HOME from C:\Java\jdk1.8.0_112 to JAVA_HOME\bin, as you suggested.

Knute, I followed your latest instructions. I think I was unclear about how I was meant to assign the value to JAVA_HOME. Here are the results of what you suggested most recently.

C:\Program Files>echo %JAVA_HOME%
JAVA_HOME\bin

C:\Program Files>path
PATH=C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin;C:\ProgramData\Oracle\Java\javapath\java;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Skype\Phone\;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\

Thanks again.
 
Campbell Ritchie
Marshal
Posts: 56598
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Dixon wrote:. . .
C:\Program Files>echo %JAVA_HOME%
JAVA_HOME\bin

C:\Program Files>path
PATH=C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin;C:\ProgramData\Oracle\Java\javapath\java;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Skype\Phone\;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\
. . . .
Is it working now? That is probably the most important question.

Have you added \bin to JAVA_HOME? That looks peculiar. You are liable to have C:\Program Files\java\jdk1.8.0_112\bin\bin in your PATH. If you go to that bin folder, does it have javac.exe in? I meant to include JAVA_HOME\bin as part of the PATH. Do you have Binn with double n at the end of your PATH?
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell and I disagree over what you should set JAVA_HOME to, but I am 99% sure that you are not supposed to have "/bin" in it.  So in your case just C:\Program Files\Java\jdk1.8.0_112.  Your PATH is correct, so once you fix your JAVA_HOME, you should be able to the command window and type:

java -version
javac -version
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!