I would like to share some utilities and useful insights that I have discovered during my first year of masters research. These include Apache Maven, a very useful dependency resolution and build automation utility for Java as well as my experiences with different free or partially free Web hosting services.
What is Apache Maven?
Apache Maven is a very powerful and useful tool for Java programmers. Its main feature is automatic dependency resolution, but it is also very customizable to include Java build options, JUnit testing and Javadoc generation.
Installing Apache Maven
Download the appropriate Apache Maven archive: apache-maven-3.2.3-bin.tar.gz for OSX/Unix or apache-maven-3.2.3-bin.zip for Windows from Here. Untar/Unzip and follow the instructions README.txt, included in the archive. More instructions available here
Using Maven from commandline
The default build script for an Apache Maven can be generated by using the following command on commandline:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
This will create a new Maven project in the current directory called myapp. Calling
mvn clean install from the commandline will build the App.java source, which represents the “Hello World” of Maven projects. Run “Hello World” with
java -cp target/my-app-1.0-SNAPSHOT.jar com.mycompany.app.App
For more advanced projects, it is important to understand the principles of how Maven works before attempting to change the generated pom.xml to include more dependencies and build options. Maven processes Java source in different life-cycle phases called goalds. According to Maven in 5 minutes:
Although hardly a comprehensive list, these are the most common default lifecycle phases executed.
- validate: validate the project is correct and all necessary information is available
- compile: compile the source code of the project
- test: test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
- package: take the compiled code and package it in its distributable format, such as a JAR.
- integration-test: process and deploy the package if necessary into an environment where integration tests can be run
- verify: run any checks to verify the package is valid and meets quality criteria
- install: install the package into the local repository, for use as a dependency in other projects locally
- deploy: done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.
There are two other Maven lifecycles of note beyond the default list above. They are
- clean: cleans up artifacts created by prior builds
- site: generates site documentation for this project
These life-cycle goals are specified in the pom.xml. Most of these life-cycle goals are included by default, but every goal can be customized to use specific settings. More information at Maven Getting Started
The dependecy resolution part of Maven is specified by the
<dependency> tags in the XML. For example, including JUnit testing in the build (included by default, but specific versions can be specified), use the following code:
Check the Maven Repository for more plugins.
Using Maven in Eclipse
Apache Maven can also be used with Eclipse. To install follow these steps:
- Download the latest Eclipse
- In Eclipse: Help->Install New Software: Enter http://download.eclipse.org/technology/m2e/releases
- Create a Maven Project
The pom.xml file can be edited in Eclipse, and the different life-cycle goals can be set as Build configurations. For a quick start, use
clean install, which will clean, compile, test and package the project.
There are many other settings and configurations available with Maven, but would be too long and complicated to explain here. Check the official Apache Maven site for more details.
Web Hosting Services
Various websites offer free or trail period Web Hosting Services, and this section is dedicated draw a comparison between the options. However, this post will focus on the lightweight and easy to setup websites, and not a production ready, heavy duty hosting solutions.
The first hosting solution is completely free, but with some restrictions. According to the website, here is the list:
- 20GB of Storage
- 200GB of Traffic to and from your site per month
- Free subdomain @t15.org
- 3 versions of PHP available, MySQL, FTP, POP3 Email, SSH Console
- Free subdomain @t15.org
- Free website builder
However, what is not included in this list is the restriction on file creation. This poses a problem for PHP scripts that create a local cache, such as Google+ Sign-in. Also, it has a 30-day inactivity shut-down. If there was no activity, the site is suspended. However, for most other applications, this lightweight solution is adequate. Usage is as simple as uploading the PHP files to the public_html folder using FileZilla or other ftp client.
Amazon Web Services
Although not free, Amazon Web Services(AWS) provides a limited Infrastructure-as-a-Service(IaaS), that is virtual machines in the cloud, for a 1-year trail period. This free Service provides the following resources:
- 750 hours of computational usage / up-time per year
- 750 hours of relational database use, 20GB of database storage
- 30GB of general storage
- Linux and Windows Server images available
- Read/write access according to Linux or Windows defaults
- 15GB of total out-bound data transfer for the 12 month period
- Free trail period to 12 month period, can continue at $0.013 per hour for a micro instance after 12 month period.
This offering is limited, but could be used for a basic prototyping of a website. If more computing power is required, it can be easily added on at relatively good pricing. For a basic web server setup, follow this tutorial
Google App Engine
Google App Engine is a Platform-as-a-Service(PaaS) which not only hosts websites, but can also host executables written in Java, Python and Go.
There are various limits on the free service:
- 5GB of general storage
- 28 instance hours per day (Auto-scaling)
- 100 E-mails per day
- 1GB of outgoing bandwidth per day
- CloudSQL not included, basic package costs $0.36 per day for 0.5GB of database storage
Check this link for more information on deployment of an app.
In comparison: FreeHostingNoAds.net provides easy-to-use and free hosting, but with file write restrictions. Both Amazon and Google App Engine have stronger storage restrictions, but more flexibility. Google App Engine also provides auto-scaling of instances to accommodate larger peak loads.
Thank you for reading this blogpost, hope it helps!