Hi, I came here from Head First Java. Per instructions, I installed JDK 6.22 to my Windows 64 laptop. I wrote the HelloWorldApp.Java application, but Windows cannot locate the compiler.
I put the HelloWorldApp.java in the directory C:/mywork
I then tried using the compiler by referencing the compiler directory, by setting the directory in the command prompt to c:/mywork and typing in "C:\Program Files\Java\jdk1.6.0_22\bin\javac HelloWorldApp.java
To which Windows responds: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.
I tried without referencing the JDK directory, i.e. just typing in "javac HelloWorldApp.java" and I got the same error message: 'javac' is not recognized as an internal or external command, operable program or batch file.
I added a JAVA_HOME variable to the environmental variables with its value as C:\Program Files\Java\jdk1.6.0_22\bin and the value of Path is "%JAVA_HOME%\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\EgisTec MyWinLocker\x86;C:\Program Files (x86)\EgisTec MyWinLocker\x64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\MATLAB\R2010a\runtime\win64;C:\Program Files\MATLAB\R2010a\bin;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files (x86)\Windows Live\Shared"
What's worse is that I took a Java class at a top CS program awhile back, and can't make it past the first page!
Once you have made the changes to your JAVA_HOME, path environment variables, you need to open a new command prompt and then try. The current values for JAVA_HOME and path look fine to me.
Can you try- javac -version at the command prompt?
Also show us what you've got when you type :
set JAVA_HOME
and
set PATH
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
mohamed sanaullah wrote:Once you have made the changes to your JAVA_HOME, path environment variables, you need to open a new command prompt and then try. The current values for JAVA_HOME and path look fine to me.
Can you try- javac -version at the command prompt?
I typed "javac -version" without the quotes, in a new cmd window, and still no recognition.
Andrew Meyer wrote:I typed "javac -version" without the quotes, in a new cmd window, and still no recognition.
One way to check if you have a correct installation- You can navigate to the bin dir of the JDK installation and then try running javac And do post what error you get when you are trying these commands.
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
mohamed sanaullah wrote:
Andrew Meyer wrote:I typed "javac -version" without the quotes, in a new cmd window, and still no recognition.
One way to check if you have a correct installation- You can navigate to the bin dir of the JDK installation and then try running javac And do post what error you get when you are trying these commands.
I executed javac.exe, and a dialogue box flashes and disappears. Here's a screenshot, in the millisecond it appeared:
As for the error when trying to execute javac in the command prompt, the error message is 'javac' is not recognized as an internal or external command, operable program or batch file.
Christophe Verré wrote:I'm still waiting for answers to this
My mistake, missed that:
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
I think it might be working now. I set the directory to the bin, executed javac. Then I typed javac followed by the directory of the java file, HelloWorldApp.java. Screenshot below:
Moving to the bin directory is not going to solve your problem.
The funny thing is that your %JAVA_HOME% is not recognized. Where did you set JAVA_HOME, and where did you set PATH ? If possible, can you post a screenshot ?
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
Christophe Verré wrote:Moving to the bin directory is not going to solve your problem.
The funny thing is that your %JAVA_HOME% is not recognized. Where did you set JAVA_HOME, and where did you set PATH ? If possible, can you post a screenshot ?
I'm not quite sure of what you're asking. I set the JAVA_HOME value through the System Properties, Environment Variables menu:
I'm not 100% sure that you can use the %...% in System variables if the referred variable is defined in User variables. Try to move JAVA_HOME from User variables to System variables, open a new command prompt, and try again "set PATH".
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
Christophe Verré wrote:That's the one I wanted to see Thank you.
I'm not 100% sure that you can use the %...% in System variables if the referred variable is defined in User variables. Try to move JAVA_HOME from User variables to System variables, open a new command prompt, and try again "set PATH".
Deleted JAVA_HOME from user variables and added it to System Variables.
Set JAVA_HOME to your java folder path (C:\Program Files\Java\jdk1.6.0_20 in my case).
Add %JAVA_HOME%\lib\; to your classpath and %JAVA_HOME%\bin\; to path.
Now you can use the set path and set classpath to check the value in the command prompt. As said by "mohamed", it should not show %JAVA_HOME%, and shud show the expanded path.
Welcome to the Ranch Nipun Arora and holger alberty.
The advice to add ....lib to your classpath is mistaken, I am afraid. Unless you have particular problems, you are better off not setting a system classpath at all.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32833
4
posted
0
holger alberty wrote: . . . i attached an screenie of my error massage . . .
Okay,no screenies. °° yeah ! that's good the "massage-thing"....hmmmmm if i leave everything else as "normal for my win 7 system ...cmd panel not even responses to : javac at all -,- ....okay i'll look into the links,thanks...although i don't think that' there's my answer....
holger alberty
Greenhorn
Joined: Nov 22, 2010
Posts: 9
posted
0
sorry but,i new it,i'm confused...my classpath is : C:\Program Files (x86)\Java\jre6\lib\ext\QTJava.zip
and i have two different paths for my programfiles one for : Program Files (x86) and one simply called :Program Files my java directory is in the last mentioned ^^ so what now ? °°.My written example from this site,has it to be,or not to be in the same directory as my whole "java-going-on's" ? (i hope someone undestands what i just meant ^^)
Andrew Meyer
Greenhorn
Joined: Nov 21, 2010
Posts: 14
posted
0
mohamed sanaullah wrote:
Andrew Meyer wrote:
Christophe Verré wrote:Mmmhh... Why isn't the variable converted ? You are using the "%" sign, right ?
Using it where?
The %JAVA_HOME% should get expanded to the actual value in your PATH variable.
Is it not? If not, how do I remediate that?
Christophe Verré wrote:In the PATH, you are using %JAVA_HOME%, right ? I was concerned about the "%" sign.
Yes, I'm using whatever is in the screenshots, which I believe is %JAVA_HOME%. To what variable are you referring?
holger alberty
Greenhorn
Joined: Nov 22, 2010
Posts: 9
posted
0
At Andrew,i am sorry for spamming my one business into your thread,i apologize ! i'll open one on my own,now
Nipun Arora
Greenhorn
Joined: Feb 03, 2009
Posts: 6
posted
0
Campbell Ritchie wrote:Welcome to the Ranch Nipun Arora and holger alberty.
The advice to add ....lib to your classpath is mistaken, I am afraid. Unless you have particular problems, you are better off not setting a system classpath at all.
Is it better to use user variables, and not system variables ? Any specific reason ?