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.
Under Window -> Preferences -> Java -> Installed JREs find your default JRE (the checked one) and hit Edit. Add jars that you want.
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.
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.
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.
© 2022 - 2024 — McMap. All rights reserved.