Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse and CLASSPATH

 
john sayeau
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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.
 
Ed Ward
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
  • 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 http://www.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
  • 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
  • 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.
 
Campbell Ritchie
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • 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.
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • 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.
 
Stephan van Hulst
Bartender
Pie
Posts: 5809
61
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Pie
Posts: 48940
60
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic