[2.1] How to package a Play application into a single, runnable JAR

914 views
Skip to first unread message

Bo

unread,
Mar 26, 2013, 4:12:56 PM3/26/13
to play-fr...@googlegroups.com
Hello!

I'm making a Play application for my Master's thesis (https://github.com/blopker/Pheme) and I need to package it as a single JAR file that I can start from another program. For instance, I'd like to be able to import the JAR file and run something like Pheme.run(); from another Java application.

Now, I've been using Java for a while, but I'm new to SBT. I've found three SBT plugins that may be useful.
For each option I am able to successfully configure the plugins.sbt file so that the plugin will download. However, I cannot for the life of me get Build.scala configured correctly. I'm starting to think this can't be done with the Play framework, which is a shame because this type of deployment could be very useful.

Does anyone know how to get one of these plugins working with Play?

Bo

unread,
Mar 26, 2013, 9:18:26 PM3/26/13
to play-fr...@googlegroups.com

I got it working! Kinda... I was able to get the onejar plug in working, but not with any ebean models. This is pretty terrible, but workable.

I did a write up here: https://github.com/blopker/one-jar-test if anyone is interested.

This thread got a lot of views, but no replies! Sad times.

Derek Williams

unread,
Mar 27, 2013, 12:46:21 PM3/27/13
to play-fr...@googlegroups.com
Bo, I saw that you were able to get sbt-onejar to work, so this may not be timely, but I was able to use YAJSW successfully. Here's a post with some details http://naoki.sato.name/lab/archives/263 Should work for Linux, OSX with some small changes to the instructions.



--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Derek Williams
Cell: 970.214.8928

Bo

unread,
Mar 27, 2013, 3:30:01 PM3/27/13
to play-fr...@googlegroups.com, der...@gmail.com
Hey Derek, sweet post.

Though YAJSW doesn't do exactly what I'm looking for (I think? Maybe I'm misunderstanding). I want my Play app to essentially be one executable Jar file that I can start from another Java application.

One Jar allows me to do that, but I'm unable to use Ebeans with it. However, for my use case this works for now!

Thanks!

Stephane C

unread,
Mar 28, 2013, 4:19:57 AM3/28/13
to play-fr...@googlegroups.com, der...@gmail.com
Bo,
Even if your app is not packaged as a single jar, you can start from another process by executing "java" with the correct args. This can be done easily using ProcessBuilder.
Be careful, I am no expert but when you are merging other people jars into your deliverable, you may accidentally violate their license (LGPL style licenses typically ).

Best
Reply all
Reply to author
Forward
0 new messages