Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

set classpath=

 
Jennifer Sohl
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I've been doing java for a few months now, and I am finally going to try and nip this problem in the bud.
Whenever I first open my DOS prompt, why do I have to key 'set classpath=' before my java program will compile? It compiles fine if just using one class, but if using multiple classes, it can't find them unless I key 'set classpath=' first.
I have c:/jdk1.3/bin in my CLASSPATH and Path system variables. I am running on W2K.
Can anyone help??
Thanks!
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I don't know if this will answer your question, but:
If I remember correctly, since jdk1.3 the SET CLASSPATH which in the past was set in your enviornment variables is no longer a necessity. However, that is only for classes that are part of the jdk package.
What you might want to do is go ahead and include the SET CLASSPATH= in your environment varibles as you did with your path to the bin dir. That may help you locate your problem. You may want to try and re-install the jdk. Also, make sure when you are talking about "multiple classes" you are using classes that are packaged with the jdk and not other classes that you have created yourself and/or downloaded as thrid party packages. When using those types of classes/packages, you will need to set your classpath either at the time of compile or in your environment variables.
Hope that makes since and helps a little.
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to make sure that the directory that holds YOUR compiled classes is in the Classpath. When you compile more than one class the system is not finding the first class when compiling the second. You also need to make sure that the directory that holds SUNs classes is in the directory. They are in the \lib subdirectory. In addition it is a good practice to include a dot reference in your classpath. That will mean that any class files that are sitting in whatever directory that you happen to be sitting in will also be found. (Just in case you are not sitting in the directory that you included as your working directory).
So your classpath should include:
classpath = .;c:/jdk1.3/lib;c:/pathToYourWorkingDirectory;
In addition, you can set this in the autoexec.bat if you don't want to do it by hand every time. Or you can create a bat file to set it for you to prevent having to retype all this all the time.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But since you're using Win2k, you won't use autoexec.bat, but rather, Right-click 'My Computer', Properties, Advanced, Environment Variables.

You can find CLASSPATH, or make a new one if it's not already there.

I'd put it in the System variables section, so you can use it no matter who you are logged in as.
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple class and I've set my classpath to the directory the class file sits in. I have no packages and I set the classpath through the environment tab of the System icon in Control Panel (Win NT). How come my application still doesn't see the class?
The call to this class is set into the accessibility.properties file. Any java application is supposed to trigger whatever class resides here.
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic