Requirements

Honestly, there is no much to install. You only need to have the Java(from 1.7) Virtual Machine and Maven(from 3.1.0) tool installed in your computer. If you already have those installed you can skip to Create your first application.

Installing Java

JSmart uses the Java as programming language and the Java Virtual Machine to run your applications. You have to make sure that you are running at least Java in version 1.7.

You can check that by executing the following command in your console:

java -version

It should print something like the following in your console:

java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

As you can see my machine is running Java 1.7.0_80. If you are using an older version please install the latest Java version from: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Installing Maven

JSmart uses a Maven tool to build and create new projects. Maven is used by the majority of Java based projects, and most likely you already have it installed on your machine. You can check that by executing the following command in your console:

mvn -version

This will print out the version of your Maven installation. In my case:

Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 23:15:32-0300)
Maven home: /opt/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-52-generic", arch: "amd64", family: "unix"

Make sure that you are using Maven 3 or greater If Maven is not available on your computer please follow the following guide to setup Maven: http://maven.apache.org/guides/getting-started

Create your first application

JSmart use a Maven feature called “archetypes“. These archetypes are blueprints that allow you generate a project from a single command. In our case we recommend the creation of JSmart base project based on our “jsmart-basic-archetype“, so you can use this project as starting point to create your own web application. Afterwards you can check the basic project structure at What is inside the project.

Go to any folder you want the project to be created and enter the following command:

mvn archetype:generate -DarchetypeGroupId=com.jsmartframework -DarchetypeArtifactId=jsmart-basic-archetype -DarchetypeVersion=1.0.0 -DarchetypeCatalog=http://www.jsmartframework.com

You will be prompted to enter the ${groupId}, ${artifactId}, ${version} and ${package} for your project.

Afterwards you can access your project named via previously input ${artifactId} and start the web application using embedded Jetty 9. Check the following commands:

cd <you_artifact_id>
mvn compile jetty:run

This will start the web container with the web application. To access it, go to browser and enter the URL http://localhost:8080.

For more examples using JSmart, take a look at the Examples page.

What is inside the project

JSmart does a lot of things via annotation and the project structure must follow some web project patterns.

For instance the .jsp files must be placed inside /webapp/WEB-INF folder, so the routes mapped will use the same name as the .jsp file but it could be overwritten via webConfig.xml file. The Documentation explains in depth how to setup your application all the things you can do with JSmart.

Basic Project

The content of the basic project created via archetype is exploded below:

|__pom.xml                       // Maven project setup including JSmart dependency
|__src
   |__main
   |  |__java
   |  |  |__${package}           // Package with same name of ${package} during archetype creation
   |  |     |
   |  |     |__bean
   |  |     |  |__HomeBean.java  // WebBean mapped on JSP to provide server side action and values for pages
   |  |     |
   |  |     |__service
   |  |        |__SpringService.java // Spring service to the injected on WebBeans
   |  |
   |  |__resources
   |  |  |__texts.properties     // Text locale based messages to provide texts for JSP and beans
   |  |
   |  |__webapp
   |  |  |__WEB-INF
   |  |     |__webConfig.xml     // Xml configuration to specify welcome-url, pattern-url, package-scan
   |  |     |__home.jsp          // JSP page for /home HTML containing map for HomeBean actions and values
   |  |
   |__test
      |__java
         |__                     // Your tests go here