1

I got my Java server deployed on Heroku. Im creating a server socket there and I can not find the way to set the PORT for this. I kinda see in Heroku logs a PORT that it gives me, but I dont know how to use it in my code. Thank you.

1 Answer 1

2

here is how you can do it

    public int getPort() {

    String port = System.getenv("PORT");

    if (port == null || port.isEmpty()) {
        port = "8888";  // default
    }


    return Integer.valueOf(port);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.