How to Tell Eclipse to Include Standard .jar Library for All Projects
Asked Answered
C

4

10

I realize that in eclipse you can specify certain .jar libraries to add for individual projects, but I was wondering if it was possible to make it such that eclipse automatically adds standard .jar's to the classpath for all projects. I'm using eclipse for a java course and would like to be able to automatically use the course's stdlib for all projects.

Columbian answered 6/2, 2011 at 4:19 Comment(0)
I
10

Under Window -> Preferences -> Java -> Installed JREs find your default JRE (the checked one) and hit Edit. Add jars that you want.

Intersect answered 6/2, 2011 at 4:50 Comment(2)
As a side note: in order to get this to work I had to change the compiler setting for 'forbidden' methods since it was an external library, at least I'm guessing that's why. I set it to ignore.Columbian
@Columbian How do you edit the compiler setting? I'm getting the same error.Calc
C
5

By default, if it's a java project then eclipse includes required jar files, but in addition if you need more jars then you could create user libraries by

Window - Preferences - Java - Build Path - User Libraries.

rather mixing JDK jars with user libraries.

Cornstalk answered 6/2, 2011 at 6:20 Comment(0)
S
0

I can't think of a way to do what you want specifically, but what I would recommend, if there were many of these jars, is to create a project to hold these jar files, put them in the projects classpath, and then set the project to export those jar files (that may be the default for jars in the lib directory, I can't remember).

Then any new projects can simply add a dependency on this "jar" project to get all the jars in there included in its build path.

Steapsin answered 6/2, 2011 at 4:28 Comment(0)
A
0

You can adapt a dependency control and build system like maven and put your dependency jars are properties for the maven modules. This way maven is in charge of putting the jars in a shared place in the maven repository and reusing them across projects. You can then use the Maven eclipse project generator to create your workspace for eclipse. If you project is getting rather big with lots of individual projects in the workspace this is a great automation solution.

Acetous answered 6/2, 2011 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.