18

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.

crockpotveggies
  • 11,654
  • 11
  • 65
  • 127
sanity
  • 33,862
  • 40
  • 131
  • 218
  • possible duplicate of [how can I specify a local jar file as a dependency in play! framework](http://stackoverflow.com/questions/7184427/how-can-i-specify-a-local-jar-file-as-a-dependency-in-play-framework) – Chango May 31 '13 at 14:43

5 Answers5

34

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
dogbane
  • 242,394
  • 72
  • 372
  • 395
  • 5
    I have added a jar to the lib folder, but when I do a "play dependencies --sync", play removes is a an unknown dependency. Is there something I can put in dependencies.yml to let play know it should be there? – DougC Jul 12 '11 at 15:55
  • simply adding the jar to lib folder and then executing "play dependencies --sync" worked for me – Hari Das Apr 10 '14 at 04:30
11

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.

Jean-Philippe Briend
  • 3,244
  • 26
  • 41
8

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

Tom Carchrae
  • 5,916
  • 2
  • 32
  • 33
5

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.

Community
  • 1
  • 1
Rich Apodaca
  • 25,799
  • 16
  • 92
  • 115
1

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

Community
  • 1
  • 1
Marcus Ericsson
  • 1,679
  • 1
  • 11
  • 13