Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
    Bookmark Topic Watch Topic
  • New Topic

'javac' is not recognized as ...

 
Ray
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
I installed j2sdk1.4.2_09 on WinXP. I set PATH=C:\j2sdk1.4.2_09\bin.

In Command prompt I can access 'java' from an arbituary directory, but not 'javac'. Got message : 'javac' is not recognized as an internal or external command.

Why is that?
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Report post to moderator
Did you verify that the directory "C:\j2sdk1.4.2_09\bin" contains a file called javac.exe?

If so, what happens when you execute "C:\j2sdk1.4.2_09\bin\javac"? Is the command recognized?
 
Ray
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Yes. javac can be accessed in c:\j2sdk1.4.2_09\bin but not other directories.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
"Rain"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it

here.

Thanks! and welcome to the JavaRanch!

Mark
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Report post to moderator
What is the output when you type "PATH" at the command prompt?
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Report post to moderator
You might also want to try "java -version" to make sure taht the java command you're executing from the path is the 1.4.whatever version from the path.
 
Ray
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
Dave, thank you first.

I tried 'java -version' and got: java version "1.4.1_02". I have JBuilder in my computer which has jdk1.4.1_02.

Does the jdk in JBuilder overrides the j2sdk1.4.2_09 I installed?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Originally posted by Rain:
Dave, thank you first.

I tried 'java -version' and got: java version "1.4.1_02". I have JBuilder in my computer which has jdk1.4.1_02.

Does the jdk in JBuilder overrides the j2sdk1.4.2_09 I installed?


Rain, read my post and change your display name.

Mark
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Report post to moderator
Path entries don't really "override" each other. The way it works is that when you type "java," the OS runs through the entires in your path variable until a match for java is found. If you want to use the new JDK when you type "java," you should make sure that "C:\j2sdk1.4.2_09\bin" is at the BEGINNING of your path variable.

Try updating the path variable as I've suggested and then execute the "java -version" command. If you do not get output telling you that the version of java is 1.4.2, then you'll know that you've not successfully updated the path variable.

Maybe you could also post what steps you're taking to set the path variable on your system.
 
Ray
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Report post to moderator
I put the %JAVA_HOME% at the front of PATH and 'javac' worked. It is clear now. Thanks Dave.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Report post to moderator
Ray, unfortunately you display name still does not meet our naming policy.

You need to include your real last name too.

Thanks

Mark
 
Andy Panday
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
i'm having this problem exactly. with this same version of java.

But even if u put C:\j2sdk1.4.2_09\bin in the PATH variable, when i type the command PATH in coomand prompt, it doesnt show the path to the bin directory.

So it doesnt see the PATH i just typed in... any other solutions?

also java -version gives me "java version "1.4.2_09" .. so thats correct


EDIT: pfff... the reason why i thought my PATH variable didnt update was that everytime u update u need to open a NEW command prompt too.. U cannot use the same one!! stupid huh... so in fact it was working all the time, but i didnt open new command prompt.

[ October 21, 2005: Message edited by: Andy Panday ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for posting your solution Andy. That's one detail that is often missed, even by those of us that know better.

Layne
 
mohd anis azinan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
YOU CAN TRY THIS MY FRIEND :

Step 1:Get into Environment Variables. I hope you know how to find it.

Step 2:Find 4 variables below:-
a) classpath
b) include
c) lib
d) path
If you can't find it...just create it...and for it's value...let it empty
for a while...

Step 3:Find location of your javac.exe
For example : C:\Program Files\Java\jdk1.6.0\bin\javac.exe

Step 4:Copy all word before javac.exe
So, what i must copy is : C:\Program Files\Java\jdk1.6.0\bin\

Step 5:Get into Environment Variables again
Now, for each variables that i have listed...add word in parentheses (.;) at the beginning of their Variable value.If it empty, just add .; into it...

Step 6:For each Variable value in each 4 listed variables, add a semicolon(;) at the end and paste what you copy in Step 4.If semicolon(;) exist, don't create it again...just paste what you copy in Step 4 after it...

Step 7:Now restart your computer and check if you still get the error message.

Step 8:If it still show the error message...get into Environment Variables again, go
to each 4 variables that i have listed...and add double quotes (") between all word that you copy in Step 4.
For example :
"C:\Program Files\Java\jdk1.6.0\bin\"

Step 9:Repeat Step 7

http://java2everyone.blogspot.com
 
Henry Wong
author
Marshal
Pie
Posts: 20892
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator

This is a 4 year old topic. I think that it is safe to assume that the original poster figure it out by now!!

Henry
 
    Bookmark Topic Watch Topic
  • New Topic