• Post Reply Bookmark Topic Watch Topic
  • New Topic

Setting the path and classpath for Windows XP  RSS feed

 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Help! I've been at this for hours.

I am constantly getting the message 'javac' is not recognized as an internal or external command...

Now. I have edited the path and classpath to try and combat this.

At present, my path looks like the following: C:\texmf\miktex\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\ ; C:\Program Files\Java\jdk1.5.0_07\bin

and my classpath looks like this: C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava .; C:\Program Files\Java\jdk1.5.0_07\lib\tools.jar

Does anyone know what I'm doing wrong? I have checked and rechecked the spellings so many times. I'm finding it infuriating.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you exit the command prompt and restart it? The changes you make to the PATH through the GUI won't effect a command prompt that is already open.
 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
Did you exit the command prompt and restart it? The changes you make to the PATH through the GUI won't effect a command prompt that is already open.


Yes, I did that. I even restarted my computer.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

The path looks potentially OK. After you set it, did you close your command window and open a new one? Changes don't affect running processes.

Once this does work, your classpath setting is going to cause other problems. The very best setting for you is -- trust me on this -- no setting at all. Clear CLASSPATH altogether from your environment and you will be all the happier for it. There's a built-in default which is correct and good.
 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ernest Friedman-Hill:
Hi,

Welcome to JavaRanch!

The path looks potentially OK. After you set it, did you close your command window and open a new one? Changes don't affect running processes.

Once this does work, your classpath setting is going to cause other problems. The very best setting for you is -- trust me on this -- no setting at all. Clear CLASSPATH altogether from your environment and you will be all the happier for it. There's a built-in default which is correct and good.



I'm afraid I tried setting the classpath to nothing at all too and got the same error messages.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you verified the javac is in the right place with

c:\progra~1\java\jdk1.5.0_07\bin\javac -version?
 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
Have you verified the javac is in the right place with

c:\progra~1\java\jdk1.5.0_07\bin\javac -version?


I'm using Windows XP, so you can go into the folder using windows and see that javac.exe is in that folder. I also tried it using the method that you suggested and it came up with javac: 1.5.0_07 and then all this other information.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if it has anything to do with the problem or not, but it looked like there was some white space before the semicolon and after the semicolon where you added the directory to the path.

Does removing the white space help?
 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
I don't know if it has anything to do with the problem or not, but it looked like there was some white space before the semicolon and after the semicolon where you added the directory to the path.

Does removing the white space help?


That's it!

What a STUPID sodding thing to not recognise it because there was white space in it. These things are incredibly subtle for someone who isn't a techie. I don't really understand why the installation process can't sort things like this out. Still - I'm sure they have their reasons.

Thank you for all your help! No doubt I'll be back.

I'm getting another error message now

I've compiled my programme by doing javac HelloUser.java and that's worked but then java HelloUser produces the following error: Exception in thread "main" java.lang.NoClassDefFoundError: HelloUser
 
fred rosenberger
lowercase baba
Bartender
Posts: 12542
48
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
two options:

1) try "java -cp . HelloUser"

2) put the . in your classpath

3) remove the classpath variable entirely.

note that all three still require you to run it from the directory where your .class files live.

edit - ok, i guess technically that's THREE options...
[ June 26, 2006: Message edited by: fred rosenberger ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem there is your CLASSPATH.

If you have a CLASSPATH set, but it doesn't contain the current directory, then you can't interpret programs in that directory if you are in the directory when you try to interpret them.

You can either remove the CLASSPATH because at this point you don't really need it, or define your CLASSPATH when you interpret with the -cp option.

java -cp . HelloUser
 
Elliot Costi
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Keith Lynn:
The problem there is your CLASSPATH.

If you have a CLASSPATH set, but it doesn't contain the current directory, then you can't interpret programs in that directory if you are in the directory when you try to interpret them.

You can either remove the CLASSPATH because at this point you don't really need it, or define your CLASSPATH when you interpret with the -cp option.

java -cp . HelloUser


I stuck the relevant folder in the classpath instead. I'm reluctant to get rid of the classpath thing totally unless other programmes on my PC depend on it. Cheers for your help!
 
Campbell Ritchie
Marshal
Posts: 55774
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reluctant to get rid of the classpath thing
You don't need to get rid of anything in the classpath. If you insert .; somewhere, anywhere, in it, it will work.

I have a classpath with several duplications in, and it never seems to have done any harm.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!