Start Play framework web service app from a Java application

62 views
Skip to first unread message

nish1013

unread,
Apr 20, 2016, 6:27:30 AM4/20/16
to play-framework

I'm trying to start Play application (2.5 version) within a standalone Java app.

The idea is to start an embedded web server that hosts the play based web service and then Java app will communicate with it.

I found https://www.playframework.com/documentation/2.5.x/JavaEmbeddingPlay

Is there any specific documentation on how to achieve this ?

Will Sargent

unread,
Apr 20, 2016, 2:06:50 PM4/20/16
to play-fr...@googlegroups.com
Hi Nish,

The link you posted is the documentation on how to do this.  You'd want to instantiate a server, from the docs:

Server server = Server.forRouter(new RoutingDsl()
    .GET("/hello/:to").routeTo(to ->
        ok("Hello " + to)
    )
    .build(),
    Mode.DEV, 19000
);


Will.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/874de79e-7407-4ae6-bc0b-5241a661fda4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

nish1013

unread,
Apr 20, 2016, 2:21:27 PM4/20/16
to play-framework
Thank you . But I have already defined routes in my play app. why it is requried to define it again ?

Will Sargent

unread,
Apr 20, 2016, 3:34:50 PM4/20/16
to play-fr...@googlegroups.com
You should specify the router you want -- if it's generated by Play automatically, it'll be in the /target/scala-2.11/routes/main/router/Routes.scala file.

On Wed, Apr 20, 2016 at 11:21 AM, nish1013 <nish...@gmail.com> wrote:
Thank you . But I have already defined routes in my play app. why it is requried to define it again ?
--
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.

nish1013

unread,
Apr 20, 2016, 4:28:02 PM4/20/16
to play-framework
Perfect . So then if I bundle the jar generated by sbt for Play app with my Java app , ideally it should solve my problem , isn't it ?
Reply all
Reply to author
Forward
0 new messages