Forums Register Login

set classpath=

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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!
Why am I so drawn to cherry pie? I can't seem to stop. Save me tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 626 times.
Similar Threads
stream corrupted exception weblogic 6.1
CLASSPATH driving me crazy
problem installing junit
Can't run anything
how to set classpath for java in mac?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:53:29.