Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Compiler Not Found, Despite Installing JDK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compiler Not Found, Despite Installing JDK" Watch "Compiler Not Found, Despite Installing JDK" New topic
Author

Compiler Not Found, Despite Installing JDK

Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
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!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Remove "\bin" from your JAVA_HOME.


[My Blog]
All roads lead to JavaRanch
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

typing in "C:\Program Files\Java\jdk1.6.0_22\bin\javac HelloWorldApp.java

You don't need to type the path. Type "javac HelloWorldApp.java" instead.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Also, you may be interested to read "How to create your first java program ?".
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
Christophe Verré wrote:
typing in "C:\Program Files\Java\jdk1.6.0_22\bin\javac HelloWorldApp.java

You don't need to type the path. Type "javac HelloWorldApp.java" instead.


I removed \bin from the JAVA_HOME value, and tried "javac HelloWorldApp.Java" and no dice. javac is still not recognized.

I used that tutorial you linked before posting, but I got stuck at the execute compiler stage.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I removed \bin from the JAVA_HOME value, and tried "javac HelloWorldApp.Java" and no dice. javac is still not recognized.

Did you open a new command prompt ?
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
Christophe Verré wrote:
I removed \bin from the JAVA_HOME value, and tried "javac HelloWorldApp.Java" and no dice. javac is still not recognized.

Did you open a new command prompt ?


Just tried that, still no recognition.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Please show your JAVA_HOME and PATH again. (and check your private messages too !)
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14

Christophe Verré wrote:Please show your JAVA_HOME and PATH again. (and check your private messages too !)


Point taken. Thank you for the prompt responses.

JAVA_HOME : C:\Program Files\Java\jdk1.6.0_22

Path : %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
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

At the command prompt, can you try the following ?
dir "C:\Program Files\Java\jdk1.6.0_22"
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
Christophe Verré wrote:At the command prompt, can you try the following ?
dir "C:\Program Files\Java\jdk1.6.0_22"


Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

Please enclose the path around t he double quotes(" ") as given by Christophe Verré.


Mohamed Sanaulla | My Blog
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
mohamed sanaullah wrote:Please enclose the path around t he double quotes(" ") as given by Christophe Verré.


Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
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.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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
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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I'm still waiting for answers to this
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
Christophe Verré wrote:I'm still waiting for answers to this


My mistake, missed that:

Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
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:

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
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:

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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".
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
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 path:

Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Mmmhh... Why isn't the variable converted ? You are using the "%" sign, right ?
Andrew Meyer
Greenhorn

Joined: Nov 21, 2010
Posts: 14
Christophe Verré wrote:Mmmhh... Why isn't the variable converted ? You are using the "%" sign, right ?


Using it where?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In the PATH, you are using %JAVA_HOME%, right ? I was concerned about the "%" sign.
holger alberty
Greenhorn

Joined: Nov 22, 2010
Posts: 11
Hey there ! is this problem solved already ? ^^

cause it seems not so °°

i have the exact same problem,i'm evry new to java...and would like to solve this...please can someone help me,too?

the thing is i'm german and so is my system ^^ but nevertheless i attached an screenie of my error massage

Cheers and hope ypu can help me !

moonfox


[Thumbnail for error_javac.png]



---this world is odd let's code another---
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3068
    
  33

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.
Nipun Arora
Greenhorn

Joined: Feb 03, 2009
Posts: 6
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.

I am attaching images of the setting at my side.


[Thumbnail for cmd_prompt.JPG]

[Thumbnail for JAVA_HOME_env.JPG]



Nipun Arora | www.interviewelements.com
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38492
    
  23
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: 38492
    
  23
holger alberty wrote: . . . i attached an screenie of my error massage . . .
Apart from the wonderful misspelling (massage ), please don't post screenshots. That error message is typical of a PATH not being set correctly. Please have a look at this FAQ, or the Java™ Tutorials "common problems" page, which addresses that particular error.
holger alberty
Greenhorn

Joined: Nov 22, 2010
Posts: 11
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: 11
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


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: 11
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
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 ?
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

Nipun Arora wrote:Is it better to use user variables, and not system variables ? Any specific reason ?

I believe it is better not to set it at all as a system or user variable, but to set it as part of your build script.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jonathan Friedman
Greenhorn

Joined: Nov 23, 2010
Posts: 1
Here is the solution:
http://www.java.com/en/download/help/path.xml
I added my path to the end with a ";" and it works now.
 
Don't get me started about those stupid light bulbs.
 
subject: Compiler Not Found, Despite Installing JDK