• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

set classpath=

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
It's a pleasure to see superheros taking such an interest in science. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic