To start the Play with Java, follow the below steps.
Step 1: The currently available Play version is 2.4.2. To work with this version, make sure that the JAVA_HOME environment variable is set to JDK8 or more.
set JAVA_HOME=<Path to JDK 8 or more where it installed> for Windows export JAVA_HOME=<Path to JDK 8 more where it installed> for Linux based
Step 2: Download the Typesafe’s Activator(Tool from Typesafe which will allow the developers to create Play project quickly. It is built on top of SBT). The Activator will be available in two formats. One is minimum downloadable artifact online version and the other one is offline fully downloadable version(suitable for developers with no internet connection). In this tutorial, we are going to use the minimum online version.
Step 3: Extract the downloaded Activator zip file and add it to the PATH environment variable.
set PATH=<Path to extracted activator folder>;%PATH%; for Windows export PATH=<Path to extracted activator folder>:$PATH: for Linux based For example,set PATH=D:\My_Learnings\typesafe-activator-1.3.5-minimal\activator-1.3.5-minimal;%PATH%;
Step 4: Now, from the command prompt use the below command to create Play for Java application. There are other options available for the activator. To know that, execute activator help command.
activator new Learning_Play_App play-java
Step 5: Now run the Play app which we created in Step 4 and see the default Play UI. From the command prompt, move to the project which we created and execute the below command. When we run the Activator, it will launch the Netty server. To stop the server, use ctrl+D
D:\My_Learnings>cd Learning_Play_App D:\My_Learnings\Learning_Play_App>activator run
First time when you run the activator, it will download all the dependencies from the central repository and will take some time to start the Play application. After the application is started on default port 9000, open the browser and send the request to http://localhost:9999 to see the default Play UI as shown below.
You are done with your first Play Application creation. In the next article, we will try to understand the Play folder structure and exporting it as our favorite IDE project(Like Eclipse, IntelliJ, etc.).