Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 239
sanity Avatar asked Jan 26 '11 14:01

sanity


People also ask

How do I find the classpath of a jar file?

To check our CLASSPATH on Windows we can open a command prompt and type echo %CLASSPATH%. To check it on a Mac you need to open a terminal and type echo $CLASSPATH.

What does it mean to add to classpath?

Simply put, the classpath is just a set of paths where the java compiler and the JVM must find needed classes to compile or execute other classes.


2 Answers

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
like image 74
dogbane Avatar answered Oct 11 '22 19:10

dogbane


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.

like image 30
Jean-Philippe Briend Avatar answered Oct 11 '22 20:10

Jean-Philippe Briend