Java

Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

Spring Logo

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Hibernate Logo

Hibernate Framework

Hibernate ORM is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

Wednesday, August 19, 2015

Spring Data Cassandra - CRUD Operations

Hi, in this post we are going to see how to connect with Cassandra NoSQL database using Spring data.

Project Structure:
Tools and Technologies:
  • Java 8
  • Spring 3.2.8
  • Cassandra 2.1.8
  • Spring-Data-Cassandra 1.0.0
  • Maven 3.0.4
Cassandra Keyspace and Table Creation:
cqlsh> create keyspace "ranga" with replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};

cqlsh> CREATE TABLE employee(id int, name text, salary float, PRIMARY KEY(id));
Maven Configuration file:
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>CassandraCRUDOperations</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>

<!-- Java Version -->
<java.version>1.8</java.version>

<!-- Spring -->
<spring-framework.version>3.2.8.RELEASE</spring-framework.version>
<!-- 4.2.0.RELEASE -->

<!-- Cassandra -->
<cassandra.version>1.0.0.RELEASE</cassandra.version>

<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>

<!-- Test -->
<junit.version>4.11</junit.version>

</properties>

<dependencies>

<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>

<!-- Spring Data Cassandra -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>${cassandra.version}</version>
</dependency>

<!-- Spring Test -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-framework.version}</version>
<scope>test</scope>
</dependency>

<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>

</project>

Cassandra database properties file:
src/main/resources/cassandra.properties
cassandra.contactpoints=localhost,127.0.0.1
cassandra.port=9042
cassandra.keyspace=ranga
Cassandra Template configuration file:
com/ranga/util/CassandraUtil.java
package com.ranga.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.data.cassandra.config.CassandraClusterFactoryBean;
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
import org.springframework.data.cassandra.config.SchemaAction;
import org.springframework.data.cassandra.convert.CassandraConverter;
import org.springframework.data.cassandra.convert.MappingCassandraConverter;
import org.springframework.data.cassandra.core.CassandraOperations;
import org.springframework.data.cassandra.core.CassandraTemplate;
import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
import org.springframework.data.cassandra.mapping.CassandraMappingContext;

/**
* Utility class for getting the CassandraOperations object.
* @author Ranga Reddy
* @version 1.0
*/


@Configuration
@PropertySource(value = { "classpath:cassandra.properties" })
public class CassandraUtil {

/**
* Constant String for Keyspace
*/

private static final String KEYSPACE = "cassandra.keyspace";
/**
* Constant String for ContactPoints
*/

private static final String CONTACTPOINTS = "cassandra.contactpoints";
/**
* Constant String for Port
*/

private static final String PORT = "cassandra.port";

@Autowired
private Environment environment;

public CassandraUtil() {
System.out.println("CassandraUtil()");
}

private String getKeyspaceName() {
return environment.getProperty(KEYSPACE);
}

private String getContactPoints() {
return environment
.getProperty(CONTACTPOINTS);
}

private int getPortNumber() {
return Integer.parseInt(environment
.getProperty(PORT));
}

@Bean
public CassandraClusterFactoryBean cluster() {
CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean();
cluster.setContactPoints(getContactPoints());
cluster.setPort(getPortNumber());
return cluster;
}

@Bean
public CassandraMappingContext mappingContext() {
return new BasicCassandraMappingContext();
}

@Bean
public CassandraConverter converter() {
return new MappingCassandraConverter(mappingContext());
}

@Bean
public CassandraSessionFactoryBean session() throws Exception {
CassandraSessionFactoryBean cassandraSessionFactoryBean = new CassandraSessionFactoryBean();
cassandraSessionFactoryBean.setCluster(cluster().getObject());
cassandraSessionFactoryBean.setKeyspaceName(getKeyspaceName());
cassandraSessionFactoryBean.setConverter(converter());
cassandraSessionFactoryBean.setSchemaAction(SchemaAction.NONE);
return cassandraSessionFactoryBean;
}

@Bean
public CassandraOperations cassandraTemplate() throws Exception {
return new CassandraTemplate(session().getObject());
}
}

com/ranga/util/MyCassandraTemplate.java
package com.ranga.util;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.cassandra.core.CassandraOperations;

/**
* Utility class for handling all CRUD Operations.
* @author Ranga Reddy
* @version 1.0
*/

public class MyCassandraTemplate {

@Autowired
private CassandraOperations cassandraTemplate;

/**
* Creating the entity.
* @param entity
* @return {@link Object}
*/

public <T> T create(T entity) {
return cassandraTemplate.insert(entity);
}

/**
* Creating the entity.
* @param entity
* @param claz
* @return T
*/

public <T> T create(T entity, Class<T> claz) {
return (T) cassandraTemplate.insert(entity);
}

/**
* Creating the list of entities.
* @param entity
*/

public <T> void createList(List<T> entities) {
cassandraTemplate.insert(entities);
}

/**
* Updating the entity.
* @param entity
* @param claz
* @return T
*/

public <T> T update(T entity) {
return (T) cassandraTemplate.update(entity);
}

/**
* Updating the list of entities.
* @param entity
* @param claz
* @return T
*/

public <T> void updateList(List<T> entities) {
cassandraTemplate.update(entities);
}

/**
* Updating the entity.
* @param entity
* @param claz
* @return T
*/

public <T> T update(T entity, Class<T> claz) {
return (T) cassandraTemplate.update(entity);
}

/**
* Get the Entity using Id.
* @param id
* @param claz
* @return T
*/

public <T> T findById(Object id, Class<T> claz) {
return cassandraTemplate.selectOneById(claz, id);
}

/**
* Delete the Entity using Id.
* @param id
* @param claz
*/

public <T> void deleteById(Object id, Class<T> claz) {
cassandraTemplate.deleteById(claz, id);
}

/**
* Delete the Entity using object.
* @param entity
*/

public void delete(Object entity) {
cassandraTemplate.delete(entity);
}

/**
* Deleting the list of entities
* @param entities
*/

public <T> void delete(List<T> entities) {
cassandraTemplate.delete(entities);
}

/**
* Deleting the all entities.
* @param claz
*/

public <T> void deleteAll(Class<T> claz) {
cassandraTemplate.deleteAll(claz);
}

/**
* Getting the all entities.
* @param claz
* @return List of entities
*/

public <T> List<T> findAll(Class<T> claz) {
return (List<T>) cassandraTemplate.selectAll(claz);
}

/**
* Getting the all entity values using specific id's data.
* @param ids
* @param claz
* @return
*/

public <T> List<T> findAll(List<Object> ids, Class<T> claz) {
return cassandraTemplate.selectBySimpleIds(claz, ids);
}

/**
* Getting the count of records.
* @param claz
* @return the count value.
*/

public <T> void truncate(Class<T> claz) {
cassandraTemplate.truncate(claz.getName());
}

/**
* Getting the count of records.
* @param claz
* @return the count value.
*/

public <T> long getCount(Class<T> claz) {
return cassandraTemplate.count(claz);
}


/**
* Checking the object exists or not.
* @param id
* @param claz
* @return true if the object exists in the database otherwise it will return false.
*/

public <T> boolean exists(Object id, Class<T> claz) {
return cassandraTemplate.exists(claz, id);
}

}
Entity Class:
com/ranga/entity/Employee.java
package com.ranga.entity;

import org.springframework.data.cassandra.mapping.Column;
import org.springframework.data.cassandra.mapping.PrimaryKey;
import org.springframework.data.cassandra.mapping.Table;

/**
* Employee Entity class.
* @author Ranga Reddy
* @version 1.0
*/


@Table(value="employee")
public class Employee {

@PrimaryKey(value="id")
private int id;

@Column(value="name")
private String name;

@Column(value="salary")
private float salary;

/**
* Default Constructor
*/

public Employee() {
super();
}

/**
* Parameterized Constructor
* @param id
* @param name
* @param salary
*/

public Employee(int id, String name, float salary) {
super();
this.id = id;
this.name = name;
this.salary = salary;
}


/**
* @return the id
*/

public int getId() {
return id;
}

/**
* @param id the id to set
*/

public void setId(int id) {
this.id = id;
}

/**
* @return the name
*/

public String getName() {
return name;
}

/**
* @param name the name to set
*/

public void setName(String name) {
this.name = name;
}

/**
* @return the salary
*/

public float getSalary() {
return salary;
}

/**
* @param salary the salary to set
*/

public void setSalary(float salary) {
this.salary = salary;
}

@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", salary=" + salary
+ "]";
}

}
Service and Impl classes:
com/ranga/service/EmployeeService.java
package com.ranga.service;

import java.util.List;

import com.ranga.entity.Employee;

/**
* Service interface for Employee to perform CRUD operation.
* @author Ranga Reddy
* @version 1.0
*/

public interface EmployeeService {
/**
* Used to Create the Employee Information
* @param employee
* @return {@link Employee}
*/

public Employee createEmployee(Employee employee);

/**
* Getting the Employee Information using Id
* @param id
* @return {@link Employee}
*/

public Employee getEmployee(int id);

/**
* Used to Update the Employee Information
* @param employee
* @return {@link Employee}
*/


public Employee updateEmployee(Employee employee);

/**
* Deleting the Employee Information using Id
* @param id
*/

public void deleteEmployee(int id);

/**
* Getting the All Employees information
* @return
*/

public List<Employee> getAllEmployees();
}

com/ranga/service/EmployeeServiceImpl.java
package com.ranga.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.ranga.dao.EmployeeDAO;
import com.ranga.entity.Employee;

/**
* Service Impl class for Employee to perform CRUD operation.
* @author Ranga Reddy
* @version 1.0
*/

public class EmployeeServiceImpl implements EmployeeService {

@Autowired
private EmployeeDAO employeeDAO;

/**
*
*/

public EmployeeServiceImpl() {
super();
}

@Override
@Transactional
public Employee createEmployee(Employee employee) {
return employeeDAO.createEmployee(employee);
}

@Override
@Transactional
public Employee getEmployee(int id) {
return employeeDAO.getEmployee(id);
}

@Override
@Transactional
public Employee updateEmployee(Employee employee) {
return employeeDAO.updateEmployee(employee);
}

@Override
@Transactional
public void deleteEmployee(int id) {
employeeDAO.deleteEmployee(id);
}

@Override
@Transactional
public List<Employee> getAllEmployees() {
return employeeDAO.getAllEmployees();
}
}
DAO and Impl classes:
com/ranga/dao/EmployeeDAO.java
package com.ranga.dao;

import java.util.List;

import com.ranga.entity.Employee;

/**
* DAO interface for Employee to perform CRUD operation.
* @author Ranga Reddy
* @version 1.0
*/

public interface EmployeeDAO {
/**
* Used to Create the Employee Information
* @param employee
* @return {@link Employee}
*/

public Employee createEmployee(Employee employee);

/**
* Getting the Employee Information using Id
* @param id
* @return {@link Employee}
*/

public Employee getEmployee(int id);

/**
* Used to Update the Employee Information
* @param employee
* @return {@link Employee}
*/


public Employee updateEmployee(Employee employee);

/**
* Deleting the Employee Information using Id
* @param id
*/

public void deleteEmployee(int id);

/**
* Getting the All Employees information
* @return
*/

public List<Employee> getAllEmployees();
}

com/ranga/dao/EmployeeDAOImpl.java
package com.ranga.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import com.ranga.entity.Employee;
import com.ranga.util.MyCassandraTemplate;

/**
* DAOImpl class for Employee to perform CRUD operation.
* @author Ranga Reddy
* @version 1.0
*/

public class EmployeeDAOImpl implements EmployeeDAO {

@Autowired
private MyCassandraTemplate myCassandraTemplate;

@Override
public Employee createEmployee(Employee employee) {
return myCassandraTemplate.create(employee, Employee.class);
}

@Override
public Employee getEmployee(int id) {
return myCassandraTemplate.findById(id, Employee.class);
}

@Override
public Employee updateEmployee(Employee employee) {
return myCassandraTemplate.update(employee, Employee.class);
}

@Override
public void deleteEmployee(int id) {
myCassandraTemplate.deleteById(id, Employee.class);
}

@Override
public List<Employee> getAllEmployees() {
return myCassandraTemplate.findAll(Employee.class);
}
}
Spring Main Configuration file:
com/ranga/configuration/MainAppConfiguration.java
package com.ranga.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.ranga.dao.EmployeeDAO;
import com.ranga.dao.EmployeeDAOImpl;
import com.ranga.service.EmployeeService;
import com.ranga.service.EmployeeServiceImpl;
import com.ranga.util.CassandraUtil;
import com.ranga.util.MyCassandraTemplate;

/**
* This is the main configuration file to create the Beans.
* @author Ranga Reddy
* @version 1.0
*/


@Configuration
@Import(CassandraUtil.class)
public class MainAppConfiguration {

/**
* Creating the EmployeeService bean.
* @return {@link EmployeeService}
*/

@Bean
public EmployeeService getEmployeeService() {
return new EmployeeServiceImpl();
}

/**
* Creating the EmployeeDAO bean.
* @return {@link EmployeeDAO}
*/

@Bean
public EmployeeDAO getEmployeeDAO() {
return new EmployeeDAOImpl();
}

/**
* Creating the MyCassandraTemplate bean.
* @return {@link MyCassandraTemplate}
*/

@Bean
public MyCassandraTemplate getMyCassandraTemplate() {
return new MyCassandraTemplate();
}
}
Client Application
com/ranga/client/Application.java
package com.ranga.client;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.ranga.configuration.MainAppConfiguration;
import com.ranga.entity.Employee;
import com.ranga.service.EmployeeService;

/**
* Client Application to perform CRUD operations.
* @author Ranga Reddy
* @version 1.0
*/


public class Application {

@SuppressWarnings("resource")
public static void main(String[] args) {

// Getting the ApplicationContext
ApplicationContext applicationContext =
new AnnotationConfigApplicationContext(MainAppConfiguration.class);

//Getting the EmployeeService object.
EmployeeService employeeService = applicationContext.getBean(EmployeeService.class);

Employee employee = new Employee(1, "Ranga", 20000);

// Create the Employee information
employee = employeeService.createEmployee(employee);
System.out.println("After Creattion Employee Info: "+employee);

System.out.println("Displaying all Employee Info ");
// Getting All Employees information and printing
List<Employee> employees = employeeService.getAllEmployees();
employees.forEach(emp -> { System.out.println(emp);});

System.out.println("Updating the Employee Info: ");
// Updating the Employee information
employee.setName("Ranga Reddy");
employee.setSalary(40000);
employeeService.updateEmployee(employee);

// Getting the Employee information based on Id
employee = employeeService.getEmployee(employee.getId());
System.out.println("After Updation Employee Info: "+employee);

System.out.println("Deleting Employee Info ");
// Deleting the Employee Information
employeeService.deleteEmployee(employee.getId());
employee = employeeService.getEmployee(employee.getId());
System.out.println("After Deletion Employee Info: "+employee);
}
}

Output:
20:48:44.253 [main] DEBUG o.s.cassandra.core.CqlTemplate - executing [INSERT INTO employee(id,name,salary) VALUES (1,'Ranga',20000.0);]
After Creattion Employee Info: Employee [id=1, name=Ranga, salary=20000.0]
Displaying all Employee Info
Employee [id=1, name=Ranga, salary=20000.0]
Updating the Employee Info:
20:48:44.376 [main] DEBUG o.s.cassandra.core.CqlTemplate - executing [INSERT INTO employee(id,name,salary) VALUES (1,'Ranga Reddy',40000.0);]
20:48:44.382 [main] DEBUG o.s.cassandra.core.CqlTemplate - executing [SELECT * FROM employee WHERE id=1;]
After Updation Employee Info: Employee [id=1, name=Ranga Reddy, salary=40000.0]
Deleting Employee Info
20:48:44.391 [main] DEBUG o.s.cassandra.core.CqlTemplate - executing [DELETE FROM employee WHERE id=1;]
20:48:44.395 [main] DEBUG o.s.cassandra.core.CqlTemplate - executing [SELECT * FROM employee WHERE id=1;]
After Deletion Employee Info: null

Monday, August 17, 2015

Java8 New Features

New Features of Java 8:

The following are the major features of Java 8:

Sunday, August 2, 2015

Changing the default port number(9000) of a Play Application

Changing the default port number  9000 of Play Application:

In order to change the default port number, we can do it in two ways:

Way 1: In the conf/application.conf file change the default port number value.
             http.port=2015

Way 2: Passing the port number value while running the application in command line or terminal.

Play 1.x:  

play run --http.port=2015

Play 2.x: 

activator "run 2015"  - browser-reload mode
activator "~run 2015" - continuous-reload mode
activator debug "run 2015" - debug mode

Reference:

  1. https://www.playframework.com/documentation/2.2.x/ProductionConfiguration
  2. https://stackoverflow.com/questions/8205067/how-do-i-change-the-default-port-9000-that-play-uses-when-i-execute-the-run?rq=1
Happy Learning!

Saturday, August 1, 2015

Play Application Structure

The Structure of a Play Application:

The structure of a Play Application is very similar to a other MVC application. There are Models, Views and Controllers folder under the app directory.  In addition to app directory it will contain some other directories like conf, log, public, project, lib, test etc.


    app                      → Application sources
    └ controllers → Application controllers
    └ models → Application business layer
    └ views → Templates
    conf
    → Configurations files
    └ application.conf → Main configuration file
    └ routes → Routes definition
    public → Public assets
    └ stylesheets → CSS files
    └ javascripts → Javascript files
    └ images → Image files
    project
    → sbt configuration files
    └ build.properties → Marker for sbt project
    └ Build.scala → Application build script
    └ plugins.sbt → sbt plugins
    lib
    → Unmanaged libraries dependencies
    logs
    → Standard logs folder
    └ application.log → Default log file
    target
    → Generated stuff
    └ scala-2.9.1
    └ cache
    └ classes → Compiled class files
    └ classes_managed → Managed class files (templates, ...)
    └ resource_managed → Managed resources (less, ...)
    └ src_managed → Generated sources (templates, ...)
    test
    → source folder for unit or functional tests

    The app directory

    The app directory contains all executable artifacts: Java and Scala source code, templates and compiled asset's sources.
    There are three packages in the app directory, one for each component of the MVC architectural pattern:
    • app/controllers
    • app/models (for default application this folder is optional)
    • app/views
    We can add our packages, for example app/utility.

    The conf directory

    The conf directory will contain the configuration files of the Play Application. There are two main configuration files:
    • application.conf - the main configuration file for the application, which contains configuration parameters.  
    • routes - the routes definition file
    The public directory
    All resources stored in the public directory are static assets that are served directly by the Web server. This directory is split into three sub-directories for Images, Css stylesheets and JavaScript files.
    In a newly-created application, the /public directory is mapped to the /assets URL path, but you can easily change that, or even use several directories for your static assets.

    The project directory

    The project directory contains the sbt build definitions:
    • plugins.sbt defines sbt plugins used by this project
    • build.properties contains the sbt version to use to build your app.

    The lib directory

    The lib directory is optional and contains unmanaged library dependencies, ie. all JAR files you want to manually manage outside the build system. If we want to use any JAR file then drop on the JAR file here and they will be added to your application classpath.

    The build.sbt file

    The build.sbt file contains the project main build declarations. The .scala files in the project/ directory can also be used to declare your project build.

    The target directory

    The target directory contains everything which is generated by the build system. It can be useful to know what is generated in this directory.
    • classes/ contains all compiled classes (from both Java and Scala sources).
    • classes_managed/ contains only the classes that are managed by the framework.
    • resource_managed/ contains generated resources, typically compiled assets such as LESS CSS and CoffeeScript compilation results.
    • src_managed/ contains generated sources, such as the Scala sources generated by the template system.
    • web/ contains assets processed by sbt-web such as those from the app/assets and public folders.

    The .gitignore files

    The generated folders should be ignored by your version control system. Here is the typical .gitignore file for the play application.
    logs
    project
    /project
    project
    /target
    target
    tmp
    dist
    .cache



    References:

    1. https://www.playframework.com/documentation/2.4.x/Anatomy
    2. http://jstricks.com/analysis-play-application-framework/
    3. http://richardstudynotes.blogspot.in/2013/01/v-behaviorurldefaultvmlo.html

    First application using Play Framework

    First application using Play Framework:

    Before going to implement the First play application, we need to know some thing about activator and it's commands:

    Activator:  
    • Typesafe Activator is a browser based or command line tool that helps developers get started with the Typesafe Reactive Platform.
    • Activator includes the sbt build tool, a quick-start GUI, and a catalog of template applications. 
    • Activator allows us to select a template that our new application should be based off.  The names of the templates are play-scala for Scala based Play applications and play-java for Java based Play applications.
    The following are the important commands of activator:
    Command name Description
    activator To run the Console
    activator ui Start the Activator UI
    activator new [name] [template-id] Create a new project with [name] using template [template-id]
    activator list-templates Print all available template names
    activator help Print this message

    Creating the new application:
    To create a new applications we need to use the activator new command.

    D:\Play\My_Practise>activator new HelloWorld
    Fetching the latest list of templates...

    Browse the list of templates: http://typesafe.com/activator/templates
    Choose from these featured templates or enter a template name:
    1) minimal-akka-java-seed
    2) minimal-akka-scala-seed
    3) minimal-java
    4) minimal-scala
    5) play-java
    6) play-scala

    (hit tab to see a list of all templates)
    > 5
    OK, application "HelloWorld" is being created using the "play-java" template.

    To run "HelloWorld" from the command line, "cd HelloWorld" then:
    D:\Play\My_Practise\HelloWorld/activator run

    To run the test for "HelloWorld" from the command line, "cd HelloWorld" then:
    D:\Play\My_Practise\HelloWorld/activator test

    To run the Activator UI for "HelloWorld" from the command line, "cd HelloWorld" then:

    D:\Play\My_Practise\HelloWorld/activator ui

    Project Structure:



    Compiling the Project:
    By using activator compile command, we can compile our application without running the server.

    D:\Play\My_Practise\HelloWorld>activator compile
    [info] Loading project definition from D:\Play\My_Practise\HelloWorld\project
    [info] Updating {file:/D:/Play/My_Practise/HelloWorld/project/}helloworld-build...
    [info] Resolving org.fusesource.jansi#jansi;1.4 ...
    [info] Done updating.
    [info] Set current project to HelloWorld (in build file:/D:/Play/My_Practise/HelloWorld/)
    [info] Updating {file:/D:/Play/My_Practise/HelloWorld/}root...
    [info] Resolving jline#jline;2.12.1 ...
    [info] Done updating.
    [info] Compiling 6 Scala sources and 2 Java sources to D:\Play\My_Practise\HelloWorld\target\scala-2.11\classes...
    [success] Total time: 135 s, completed Jul 29, 2015 11:52:10 PM

    Running the Project:
    By using activator run command, we can run the application.

    D:\Play\My_Practise\HelloWorld>activator run
    [info] Loading project definition from D:\Play\My_Practise\HelloWorld\project
    [info] Set current project to HelloWorld (in build file:/D:/Play/My_Practise/HelloWorld/)

    --- (Running the application, auto-reloading is enabled) ---

    [info] p.a.l.c.ActorSystemProvider - Starting application default Akka system: application
    [info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

    (Server started, use Ctrl+D to stop and go back to the console...)


    Testing the Project:
    By using activator test command, we can test the application.

    D:\Play\My_Practise\HelloWorld>activator test
    [info] Loading project definition from D:\Play\My_Practise\HelloWorld\project
    [info] Set current project to HelloWorld (in build file:/D:/Play/My_Practise/HelloWorld/)
    Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js.
    [info] Compiling 2 Java sources to D:\Play\My_Practise\HelloWorld\target\scala-2.11\test-classes...
    [info] D:\Play\My_Practise\HelloWorld\test\ApplicationTest.java: D:\Play\My_Practise\HelloWorld\test\ApplicationTest.java uses or overrides a deprecated API.
    [info] D:\Play\My_Practise\HelloWorld\test\ApplicationTest.java: Recompile with -Xlint:deprecation for details.
    [info] - application - Creating Pool for datasource 'default'
    [info] - play.api.libs.concurrent.ActorSystemProvider - Starting application default Akka system: application
    [info] - play.api.libs.concurrent.ActorSystemProvider - Shutdown application default Akka system: application
    [info] - application - Shutting down connection pool.
    [info] Passed: Total 3, Failed 0, Errors 0, Passed 3
    [success] Total time: 18 s, completed Jul 30, 2015 12:00:49 AM

    Debugging the Project:
    By using following command, we can debug the application.
    activator -jvm-debug <port> 

    $ activator -jvm-debug 9999
    When a JPDA port is available, the JVM will log this line during boot:
    Listening for transport dt_socket at address: 9999

    Happy Coding!