aspose file tools*
The moose likes Beginning Java and the fly likes 'javac' is not recognized | Special case Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Watch " New topic
Author

'javac' is not recognized | Special case

Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hello,

I have installed java in my system with all perquisites.
I am using Windows XP. I've set JAVA_HOME variable and set Path as %JAVA_HOME%\bin in environment variables.

Later I open command prompt and run java -version. It shows correct installed version of Java on my machine.

Special case: Whenever I run javac command, it always shows me 'javac' is not recognized as an internal or external command, operable program or batch file.
I don't understand that, if my JAVA_HOME path is correct and contains javac.exe file, then why above message is shown?
Please respond me asap.

Thanks,
Vaibhav
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

You did install the JDK and not just the JRE, did you? And if so, the JAVA_HOME is pointing to the JDK folder and not the JRE folder, right?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18997
    
  40


Did you install the JDK? Or just a JRE?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11480
    
  16

Look and see if you HAVE a javac.exe.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Yes, I've intalled jdk 1.6 and obviously, JAVA_HOME is pointing to jdk. As I told earlier, I manually checked in my JAVA_HOME\bin folder to find javac.exe.
javac.exe is already present in JAVA_HOME\bin folder.

Also, if JAVA_HOME is not recognizable, then I can't run java -version command directly.
I can't run javac command even javac.exe was present in my JAVA_HOME\bin folder.

Interestingly, when I double-click javac.exe file, it was running. But while typing javac command in command prompt, it shows 'javac' is not recognized......

Regards,
Vaibhav
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3739
    
  16
Vaibhav Goel wrote:Also, if JAVA_HOME is not recognizable, then I can't run java -version command directly.


Actually that may not be true. You probably have a java.exe in the Windows or Windows\System32 directory. This will run the jave.exe in your JRE which it will find using some registry settings (it doesn't need to be in your path).
So if it is finding java.exe but not javac.exe, it may mean your JAVA_HOME variable is wrong.


Joanne
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39869
    
  28
Print out the contents of %JAVA_HOME% and %PATH%, and let us have a look at them.
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
JAVA_HOME = C:\Program Files\Java\jdk1.6.0_23
Path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; C:\Program Files\Windows Imaging\; %JAVA_HOME%\bin

Regards,
Vaibhav Goel
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I would also test:

java -fullversion
$JAVA_HOME/java -fullversion

and ensure they are the same (having access to the 'which' command would be useful at this point)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

spot the Linux user Please translate instructions as necessary
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hello David,

Here it is:-
C:\>java -fullversion
java full version is "1.6.0_23-b05"

Regards,
Vaibhav Goel
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There were two lines to test, the aim is to ensure that they are they report the same thing.
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hello David,

It is showing below results:
java -fullversion = java full version is "1.6.0_23-b05"
$JAVA_HOME/java -fullversion = '$JAVA_HOME' is not recognized as an internal or external command, operable program or batch file.

Regards,
Vaibhav Goel
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Yes, it should be
%JAVA_HOME%\java -fullversion
For windows.
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hello David,

It shows below result:
C:\>%JAVA_HOME%\java -fullversion
'C:\Program' is not recognized as an internal or external command, operable program or batch file.

Regards,
Vaibhav Goel
Mike Rainville
Ranch Hand

Joined: May 29, 2004
Posts: 36
Vaibhav Goel wrote:JAVA_HOME = C:\Program Files\Java\jdk1.6.0_23
Path = %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; C:\Program Files\Windows Imaging\;_%JAVA_HOME%\bin

Regards,
Vaibhav Goel


If there's a space before %JAVA in your path variable, please try removing it. (At the position of the bold underscore above.)
Vaibhav Goel
Ranch Hand

Joined: Jul 05, 2007
Posts: 40
Hello Mike,

Great!!!
It works fine now. But please tell me two things.
1) Why it does not read space as other paths also contain space?
2) If there was a small space problem, then how come it executes java command?

Thanks,
Vaibhav Goel
Mike Rainville
Ranch Hand

Joined: May 29, 2004
Posts: 36
Vaibhav Goel wrote:Hello Mike,

Great!!!
It works fine now. But please tell me two things.
1) Why it does not read space as other paths also contain space?
2) If there was a small space problem, then how come it executes java command?

Thanks,
Vaibhav Goel


1) On Windows XP or OS X, I have never even considered using any blanks, except in a quoted file name; I have no idea why they might work in some cases but not others.
2) You may have had a JRE installed before... (Check the Control Panel for the currently installed versions of Java.)

I'm happy it's working for you now.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

David O'Meara wrote:(having access to the 'which' command would be useful at this point)

UnxUtils
The only problem I have with that with my Windows 7 64 bit machine is that "df" is no longer working.

Vaibhav Goel wrote:1) Why it does not read space as other paths also contain space?
2) If there was a small space problem, then how come it executes java command?

1) Apparently Windows isn't smart enough to trim all paths. As such, the Java part of the path was " C:\Program Files\Java\jdk1.6.0_23" which is not the same as "C:\Program Files\Java\jdk1.6.0_23".
2) Read Joanne Neal's post.
 
Consider Paul's rocket mass heater.
 
subject: 'javac' is not recognized | Special case