sanity
sanity

Reputation: 35772

How do I add Jars to the classpath in Play Framework?

My project needs to use some third-party jars. I assume I drop these in the lib/ directory in my project, but where do I configure Play to add them to the classpath?

I'm developing in Eclipse, and I know I can add them to the Eclipse project's build path, but this won't necessarily make Play reference them when it runs.

Upvotes: 18

Views: 34350

Answers (5)

Marcus Ericsson
Marcus Ericsson

Reputation: 2049

This answer really helped me. Slick way to add jars through inside conf/dependencies.yml https://stackoverflow.com/a/7185133/3439

Upvotes: 1

Rich Apodaca
Rich Apodaca

Reputation: 29004

Follow the instructions given here:

How can I specify a local jar file as a dependency in Play! Framework 1.x

If using Eclipse, follow this with:

$ play ec

Be sure to restart your development server.

Upvotes: 5

Tom Carchrae
Tom Carchrae

Reputation: 6486

Both of the answers so far are wrong because as soon as you sync it will delete them. It also starts to go around the package management feature of play.

Other methods (eg, Maven/etc) to include jars are listed here http://www.playframework.org/documentation/1.2.3/dependency

There is also a post in the Play mailing list here: http://groups.google.com/group/play-framework/browse_thread/thread/b54e4e25ae49161b

Upvotes: 8

Jean-Philippe Briend
Jean-Philippe Briend

Reputation: 3515

Do not forget to do a

play ec

or

play eclipsify

when you add new jars in the lib folder. If you don't, Eclipse won't see them.

Play! runtime automatically finds third-parties jars from lib folder so don't worry for runtime.

Upvotes: 11

dogbane
dogbane

Reputation: 274522

Play automatically adds all jars in the application's lib directory to the classpath.

To quote:

A play application classpath is built as follows (in this order):

* The /conf directory for the application
* The $PLAY_PATH/framework/play.jar
* All jar files found in your application /lib directory
* All jar files found in the $PLAY_PATH/framework/lib directory

Upvotes: 35

Related Questions