Tuesday 12 November 2013

Cool tool of the Day: Random.org


File this one under NICE!!!



The site random.org says about its self:

RANDOM.ORG offers true random numbers to anyone on the Internet. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
Random values from the environment ... excellent!
None of the pseudo-random values you get from normal random number generators.

Friday 1 November 2013

Cool tool of the day: Sitemesh

Why Use SiteMesh?

SiteMesh is a lightweight and flexible Java web application framework that applies the Gang of Four decorator pattern to allow a clean separation of content from presentation.

I am posting it here as I have used this tool before and really like it but I just spent 10 minutes attempting to recall what it was called.

The jars for site mesh can be found on the Maven repository or but pasting this into your POM.xml:


<dependency>
    <groupId>opensymphony</groupId>
    <artifactId>sitemesh</artifactId>
    <version>2.4.2</version>
</dependency>
            

Setting up Eclipse (again)

I have documented the setting up of eclipse before but in the almost two years since that post I have learned a few new tricks. SO I'm documenting them here in case they are useful to someone else.

Java JDK

You will probably have Java installed, but it will only be the JRE, which will hot have all the environment variables established. The JDK can be found by searching on Google and it will probably be the top link.
I have this time around down loaded the version 7 JDK from here (http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html). (Don't forget to pick the right version and accept the licensing  terms).

On a windows PC the easiest location to install all of these files is under a single directory structure ... with NO spaces in the name.
I will use "c:\development" throughout this post (cos it's what I use).

So:
  1. Download the JDK installer;
  2. Place it in a new folder  "c:\development\java";
  3. Run the installer (as administrator);
  4. Wait for it to start & press the next buttons;
  5. At the Optional Features deselect the "Public JRE" as you already have one;
  6. Change the installed directory to  "c:\development\java\jdk1.7.0_45\" (where 1.7.0_45 is the JDK version);
  7. Now install by pressing next;
  8. Set an environment variable JAVA_HOME = C:\development\java\jdk1.7.0_45;
  9. Add to the PATH environment variable %JAVA_HOME%\bin;
  10. Open a command prompt and check that the maven command "java-version" runs and gives the correct version.

Maven

Since my last version of this install guide I have been working with Maven, which is a build tool. I had produced a nice set of ANT scripts to do what MAVEN does but I have decided that this is just too much like reinventing the wheel.

So:
  1. Download the zip;
  2. Place into a new folder "c:\development\maven";
  3. Extract the files to  "C:\development\maven\apache-maven-3.1.1";
  4. Create an environment variable M2 = C:\development\maven\apache-maven-3.1.1;
  5. Add to the PATH environment variable %M2%\bin;
  6. Open a command prompt and check that the maven command "mvn -version" runs and gives the correct version.

Eclipse 

With the JDK set up now install the version of Eclipse you prefer.
My current favorite is the Spring Tool Suite (STS) since it comes with may of the tools and plugins pre-installed.

So:
  1. Download the latest STS; from http://spring.io/tools/sts/all ensuring you get the right version for your OS
  2. Place it in a new folder called "c:\development\eclipse";
  3. Run the installer (as administrator);
  4. Accept the licensing agreement;
  5. Accept the default installation location which should be C:\development\eclipse\springsource;
  6. Install all the toys;
  7. Set up the JDK path to be C:\development\java\jdk1.7.0_45;
  8. It may complain that a 32-bit or 64-bit version is needed which means you made a mistake at step #1;
  9. When prompted for a short cut group call it "Java Development";
  10. Launch the tool set to ensure it works;
  11. When prompted for a workspace create one with out spaces ie. "C:\development\projects\default-eclipse";
  12. You may be prompted to install any updates if they exist;
  13. Create a "Hello World" project and check whether you have Java set up correctly;

Eclipse plugins (optional)

Having installed Eclipse it is now a mater of installing a set of plugins. These vary accourding to taste and your development purpose; mine is Java web development.
I've written about the set of plugins I use before (here, & here and here). 
I'm not going to detail which ones I'm just going to list those that I use and include a 'bookmark.xml' import to list them.
The Plugins I use are:
  1. Sysdeo JSP/Tomcat Manager This plugin allows you to start or stop the tomcat environment and perform remote debuging;
  2. Log4e - Log4E is an Eclipse Plugin which helps you to use your logger easily in Java Projects; 
  3. StartExplorer- This plug-in gives you a convenient way to examine a file or a folder outside the Eclipse workspace with your file manager or open a shell/cmd.exe  and do all this by adding a few entries to Eclipse's context menus.
  4. SubEclipse - Links to your subversion source control.
  5. Aptana Studio -  HTML, CSS etc editing
 
 Interesting ones:
  1. C# development

XAMPP

This has to be the sweetest install of the set. It is an entire Apache LAMP stack installer with Tomcat included.
The best version if you are installing to windows is the full instalation tool sooner than the zip version.

So:
  1. Download the latest XAMPP;
  2. Place it in a new folder called "c:\development\xampp";
  3. Run the installer (as administrator);
  4. Follow the next buttons and select all the toys;
  5. Select the installation to c:\development\xampp\1.8.3 (where 1.8.3) is the current version;
  6. Wait a long time for the installation top complete;
  7. Start the control panel and start up HTTPD;
  8. Open a browser and check http://localhost, if you don't get a page titled XXXX then you may have something else running on port 80.
    The usual culprits are IIS or Skype these systems need to be configured to use any thing other than 80,443, 8080, 8443 (which are all ports used by Httpd & Tomcat);
    Shut those services down or change their ports (see articles on IIS or Skype respectivly) and retry (PS. don't forget to force your browser to refresh the page or you could be thinking it is still there).
  9. Tomcat should have its admin user set up.
    You can check this by browsing to http://127.0.0.1:8080/manager/status.
    If it fails shut down tomcat & edit the web-users.xml file (in the above config this is C:\development\xampp\1.8.3\tomcat\conf\web-users.xml);
    Add a set of nodes as follows:
    <role rolename="manager-gui"/>
    <user username="tomcat" password="s3cret" roles="manager-gui"/>
    Then restart.
<< Previously in this series