Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving port number in-application using Play Framework

I have two Play framework web applications running on my system on ports 9001 and 9002. I was wondering if there was any way I could retrieve which port they were running on from within my Java code.

Is this possible?

like image 221
chuuk Avatar asked Jun 24 '12 16:06

chuuk


People also ask

How do I change the port number in play framework?

For changing the port, go to your project root folder and hit: activator "run 8008" in command prompt / terminal. and that's it.

What is the default port for Play application?

Overriding configuration with system properties The default is to listen on port 9000 at the 0.0. 0.0 address (all addresses).

What is plug and play framework?

Abstract: Polygraph is a tool to quantify system behavior that violates serial execution of transactions. It is a plug-n-play framework that operates externally to the system at the conceptual granularity of entities and their relationships.


1 Answers

Yes. You can get the port like this:

int port = Integer.parseInt(Play.configuration.getProperty("http.port", 9000));

Of course, you have to import the class play.Play.

like image 103
Carsten Avatar answered Sep 28 '22 16:09

Carsten