aspose file tools*
The moose likes Beginning Java and the fly likes Class Path Problem with windows 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class Path Problem with windows 7" Watch "Class Path Problem with windows 7" New topic
Author

Class Path Problem with windows 7

Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Hello i'm sorry i know this has been covered before and i'm still stuck and i can't see what i'm doing wrong.

I've just got a new computer and i tried to set the class path the way i did with windows xp but it's not working. This is what i have done. I added a Path variable to user variables and added C:\ Program Files (x86)\Java\jdk1.6.0_20/bin as the variable value. But when i got to command prompt and type javac HelloWorld.java it just tells me javac is not recognised as an internal or external command. (my program isn't hello world but just so you get the idea...);

Also another problem is after trying this and it not working i tried to add a path to the system variables. I added a new path variable but i think once i did that it deleted the one that was already there. Is that going to mess up my computer? Does anyone know what the default path variable for windows 7 is? Maybe i could just add it again.

I'm pretty sure i've got the right destination as i typed cd to change directory and when i typed C:\ Program Files (x86)\Java\jdk1.6.0_20/bin it changed to that. And i noticed if i typed in the destination wrong its just made an error.

Please help. I've been enjoying learning programming and i've made a lot of progress, more then i ever thought i would, but this side of computers just stresses me out and i hate it. I'm dying to get started again and i can't until i've sorted this out.




Moguluri Ravi Kiran
Ranch Hand

Joined: Apr 16, 2010
Posts: 62

just type "envi" in the search box in the START BUTTON,

select "Edit The System Environment Variables"

click "Environment Variables"

click "new" in system variables.

now ---- var name = path;
var value = C:\ Program Files (x86)\Java\jdk1.6.0_20\bin;

Over....
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Moguluri Ravi Kiran wrote:just type "envi" in the search box in the START BUTTON,

select "Edit The System Environment Variables"

click "Environment Variables"

click "new" in system variables.

now ---- var name = path;
var value = C:\ Program Files (x86)\Java\jdk1.6.0_20\bin;

Over....


Thanks but I've already tried this. And i just did it again following your instructions to the letter and it's still not working.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
This sort of problem comes up very frequently. You need to set a system PATH or at least a user PATH, but you ought not to set a system classpath.

That PATH entry looks correct, but you ought to check it very carefully; the tiniest spelling error will cause it to fail. By the way, the "not recognised" error only occurs when you have an incorrect PATH, so you may not have a classpath problem as you thought.
Look at this Java™ Tutorials link, and find the "common problems" page. The error about "not recognized" is the first one you see. That should give you advice about how to set it correctly. I suspect writing "new" is incorrect because you will already have a PATH set up by Windows. You ought to edit the existing PATH and not try to create a new one.
Don't know whether you have deleted the old PATH, but I suspect half your applications will fail to run if you do
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Campbell Ritchie wrote:This sort of problem comes up very frequently. You need to set a system PATH or at least a user PATH, but you ought not to set a system classpath.

That PATH entry looks correct, but you ought to check it very carefully; the tiniest spelling error will cause it to fail. By the way, the "not recognised" error only occurs when you have an incorrect PATH, so you may not have a classpath problem as you thought.
Look at this Java™ Tutorials link, and find the "common problems" page. The error about "not recognized" is the first one you see. That should give you advice about how to set it correctly. I suspect writing "new" is incorrect because you will already have a PATH set up by Windows. You ought to edit the existing PATH and not try to create a new one.
Don't know whether you have deleted the old PATH, but I suspect half your applications will fail to run if you do


Hi thanks for the reply,

First of all i should say i think i may have been using the term class path incorrectly. I don't know that the hell i'm talking about haha.

I only tried to add a new path.. I first tried to add it to the user variables but it didn't work, so then i tired to add it to the system variables and did indeed seem to overwrite what was already there. By adding a new variable path it seemed to get rid of the old one.

I then went back and tried to alter the path again in the user variables. But it didn't work despite checking the directly over and over again. Also by typing that directory in the command line it would switch to it which makes me think it was right.

Anyway as i had deleted a path in the system variables i decided to use system restall or some kind of dell equivilent. So now that path i deleted is back. I now have to download again all the java software and i will be trying again!
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
OK i've got it working now!

I think because i had deleted that path in the system variables that was stopping it working. Everything sorted now. Thanks Campbell for your detailed reply i really appreciate it!
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
Ok this is unbelievable! It started saying javac is not a external command bla bla bla again. So i thought what on earth have i done different since it did work. I thought well i had put the command prompt desktop icon in the docker that windows 7 has at the top of the screen. I thought it couldn't be that but i removed it from the docker started it up and tried again....and now it worked fine. So i then put the command prompt icon back in the dock again and started it up just to be sure, and sure enough it doesn't work from there. So that was the problem.

Weird eh? Oh well thought i better write this here cause someone one day might have the same problem. Nice to know i didn't do anything wrong!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
It may be necessary to restart the command prompt before it recognises the new PATH. Having found the intallation instructions, it says in §4 that the PATH takes effect in new command prompt windows.
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
It was just the windows 7 dock that was the problem.

When i open up command prompt from just a desktop icon it works fine, when i open it up form the icon on the dock it can't find javac.

When opened from the dock command prompt seems to be different as it has this written along the top "C:\Windows\system32\cmd.exe". When command prompt is just opened up from he desktop it only has this written on the top "Command Prompt".
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

This page explains with pictures how to set environment variables in Windows 7:

How to Add, Remove or Edit Environment variables in Windows 7?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Neil Cartmell
Ranch Hand

Joined: Feb 13, 2010
Posts: 150
I appreciate the replies but just so everyone knows that the problem has been sorted for a while now. And it turns out it was some kind of bug with the docker on windows 7 and not my fault as i was doing everything as i should.


As Campbell pointed out the command prompt needs to be closed and repopend after setting the path. And allthough i was doing just that everytime i altered the path i think by putting it in the docker on windows 7 it was not closing properly or it wasn't updating. I litterally had one desktop icon of command prompt and one icon in my docker, when i opend it from the desktop it could find javac and when i opened it from the docker it could not. I repeated this process several times. But when i deleted the icon from the docker and added a new icon there it then worked fine. So if i had just never put the icon in the docker then i never would have had this problem.

Thanks for the replys but this problem has been sorted for a while and there is no need to reply for my benefit, but of course if you think your information could help someone else then go ahead.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Well done sorting it out
 
 
subject: Class Path Problem with windows 7