implements Elegance {

// Elwyn Malethan's musings on software development, mountain biking and general navel–gazing...

Articles tagged with 'world'

Introducing SeemoreJ: Part #1 Hello World

I've been mentioning SeemoreJ in passing for a while in my posts on here. I've mentioned that it is a yet another Java web framework and that it is inspired by my experiences working with Ruby on Rails and Merb (soon to be one and the same thing). Also, there‘s a link at the bottom of every page. So I think it‘s high time I stopped faffing. It‘s in a pretty reasonable state now so I think it‘s time to release it as an open–source project.

I hasten to add at this point that I am in no way under the illusion that SeemoreJ will become popular or attract (m)any users. I developed it because of my frustration with the verbose and heavyweight frameworks that were already available. I wanted to bring some of the simplicity and expressiveness that I experienced working with Ruby into my Java development.

Essentially, SeemoreJ allows me write web applications quickly, efficiently and pleasurably. That‘s my only motivation. If others find it useful or draw inspiration from it as well, that‘s a bonus.

Getting started

I think that one of the big facilitators in the uptake of rails is the easy bootstrapping of your fist project, this page makes it look friendly. So this section is going to be inspired by that page. Well... without all the pretty graphics...

Java

I‘ve been using Java 6 for my work. SeemoreJ will probably work with Java 5 just as well. Follow those links and follow the instructions for your platform.

Alternatively, if you have Ubuntu, like me, the following whould do the trick.

~$ sudo apt-get install sun-java6-jdk

Maven

Maven is a build management tool (like Make and Rake), which I think will completely replace Ant as the build tool of choice for most Java developers. Get the latest version here then follow the installation instructions for your platform. Alternatively, if your using Ubuntu, just type

~$ sudo apt-get install maven2

Then check Maven is installed by running mvn -v. You should see something like this.

~$ mvn -v
Maven version: 2.0.8
Java version: 1.6.0_06
OS name: "linux" version: "2.6.18-xenu" arch: "i386" Family: "unix"

Starter application (or archetype)

This is the Maven equivalent of running rails my_app. It‘s a little more verbose but we‘ll only ever have to do it once per project.

~$ mvn archetype:generate -DarchetypeCatalog=http://maven.malethan.com/repo/archetype-catalog.xml

Select seemorej-example-archetype from the list, this will probably be number 1, since I have no other archetypes there at the time of writing. Select a suitable groupId (e.g. com.mycompany) artifactId (e.g. myapp) and accept the defaults for the rest.

Now change into the project directory and type the following.

~/myproject$ mvn jetty:run-exploded

Then visit http://localhost:8080/index.html

Voila! You now have a running SeemoreJ application. Now let‘s have a look around the application source.

.
|-- pom.xml
`-- src
    |-- main
    |   |-- java
    |   |   `-- com
    |   |       `-- mycompany
    |   |           `-- HelloController.java
    |   |-- resources
    |   |   |-- hibernate.cfg.xml
    |   |   |-- hibernate.properties
    |   |   `-- log4j.xml
    |   `-- webapp
    |       |-- WEB-INF
    |       |   |-- app
    |       |   |   |-- default
    |       |   |   |   `-- default.jsp
    |       |   |   `-- hello
    |       |   |       `-- world.jsp
    |       |   |-- common
    |       |   |   |-- _flash.jsp
    |       |   |   `-- taglibs.jsp
    |       |   |-- decorators
    |       |   |   `-- application.jsp
    |       |   |-- decorators.xml
    |       |   |-- urlrewrite.xml
    |       |   `-- web.xml
    |       |-- javascripts
    |       |   `-- prototype.js
    |       `-- stylesheets
    |           `-- application.css
    `-- production
        `-- resources
            `-- hibernate.properties

In my next post on the subject I‘ll show you how to set up a simple CRUD application, based on a Hibernate POJO. Also, at some point or other I‘ll create a project on Google Code, just in case anybody is interested in the source.

First published on Apr 22, 2009. Last updated on: Dec 30, 2009.