• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eclipse and CLASSPATH

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know how to set my classpath globally (for all projects) on eclipse?
I know how to do it from the os and then use the jdk to compile but I'd like to not have to set it up on every eclipse project.

I'm going through a text book that uses the same classes regularly and I 'd like to not have to add the build path to each project individually.

Thanks.
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi John.

I think this should probably be over in IDEs, Version Contol and other tools but I'll give it a go anyway.

I'm not in front of an Eclipse window at the moment but I am using RAD which is based on Eclipse.
In RAD if I go to "WINDOW->Preferences->Java->Build Path" off the menu there is an entry for Classpath Variables and User Libraries. It's may not be exactly the same for straight Eclipse but should be similar.

Hope this helps.

...Actually after poking around over in the IDE forum I realized that what I said above may not be what you're asking.
Have a look at this thread, it may be more helpful https://coderanch.com/t/106042/vc/Eclipse-add-log-properties-classpath
Except for all the log4j static of course.

 
john sayeau
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been there and it asks for a variable name and a folder path.
I tried the folder path and guessed at a variable name "mindview" (arbitrarily picked) and it didn't work.
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you guessing at a variable name? This is where you define the path variable. You will still likely need to add it to each project. Defining it here simply makes it easier to do so. You may be able to setup a project template in Eclipse, but that is beyond me.
Sorry can't be of more assitance.
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to define a global CLASSPATH for all applications? Answer: not at all. You should neither set a system-wide CLASSPATH on the OS nor on an IDE if at all possible. If you need to set anything to compile, that would be the PATH. If you are getting anything to compile at all, you probably have a correct PATH already, and should not change anything else.
For each application, you can set the classpath with the -cp option. This is better, since each application will need a different classpath.
 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

john sayeau wrote:Does anyone know how to set my classpath globally (for all projects) on eclipse?...


I'm not sure why you are trying to do this in the first place. If you are using your own build script (Ant etc...) within the Eclipse then you can define the relevant classes/libraries in the script itself. Or if you rely on the Eclipse generated project then you don't have to worry, you just have to add the libraries etc.. in the Java build path of the project. After all each project has different dependencies.
 
Saloon Keeper
Posts: 15527
364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:How to define a global CLASSPATH for all applications? Answer: not at all. You should neither set a system-wide CLASSPATH on the OS nor on an IDE if at all possible. If you need to set anything to compile, that would be the PATH. If you are getting anything to compile at all, you probably have a correct PATH already, and should not change anything else.
For each application, you can set the classpath with the -cp option. This is better, since each application will need a different classpath.


I like to declare at least one global classpath, because I generally use the command line to run my programs, and for some quick test programs I am too lazy to type the classpath in the prompt. But that's neither here nor there.
 
john sayeau
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to do this because I'm working my way through the "Thinking in java" book. I downloaded a bunch of classes from the author's site and they are in one folder. When I'm experimenting with some of the code in the book I find I almost always have to use import to access his classes. I'd like not to have to set up every little project I do to be able to import that namespace. These are not real world projects , just learning exercises. If there was a way to do this globally while I'm going through the book, it would save me some time doing a repetitive task.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote: . . . I like to declare at least one global classpath, . . .

What does it read? I would only use one "global" classpath . . . "." And there is no point in setting that, unless something else has already set its own global classpath.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic