Wednesday, 18 December 2013

Cool tip of the day: find that port on a windows PC

I get fed up of never being able to find the port of a particular process on a windows PC.
It is easy under Unix as you can use Grep.
So here is a reminder on how to do it for windows:

netstat -ano | findstr <Port>

Or for the process:

netstat -ano | findstr <PID>

Or for an established connection:

netstat -ano | findstr :80 | findstr ESTABLISHED

See the following other references:

Tuesday, 17 December 2013

Cool tip of the Day: Isotope Javascript framework


This set of tags is scheduled to be part of a project I am working on ... but it is sooooo cool that I have to tell you about it!

Just try it click a few of the modes to see it in action!

Isotope

Features
Layout modes: Intelligent, dynamic layouts that can’t be achieved with CSS alone.
Filtering: Hide and reveal item elements easily with jQuery selectors.
Sorting: Re-order item elements with sorting. Sorting data can be extracted from just about anything.
Interoperability: features can be utilized together for a cohesive experience.
Progressive enhancement: Isotope’s animation engine takes advantage of the best browser features when available — CSS transitions and transforms, GPU acceleration — but will also fall back to JavaScript animation for lesser browsers.

Isotope requires jQuery 1.4.3 and greater.

Thursday, 5 December 2013

UNICODE and Surrogate Characters

I have been attempting to save data to a MySQL db and getting a very puzzling error.

Incorrect string value: '\xF0\x90\x8D\x83\xF0\x90...' for column 'alternatenames'
A bit of searching lead me to believe that this was entirely down to unicode characters, but it is more complex than that.
But first, ensure that your connection string has:
${database.url}?amp;useUnicode=true&amp;characterEncoding=UTF-8"
Then ensure that the columns to store the characters are:

  • CHARACTER SET utf8

    or
  • CHARACTER SET utf8mb4

Finally check the way your characters are represented as you could be attempting to store UTF-16 "surrogate pairs". The term "surrogate pair" refers to a means of encoding Unicode characters with high code-points in the UTF-16 encoding scheme. I wasn't able to get UTF-16 to work with Hibernate so I have resorted to stripping this data.
The following functions assisted me in cleansing the data:

    /**
     * I am facing a situation where i get Surrogate characters in text that i am saving to MySql 5.1. As the UTF-16 is not supported in this, I want to remove these surrogate pairs manually by a java method before saving it to the database.
     * http://stackoverflow.com/questions/12867000/how-to-remove-surrogate-characters-in-java
     * @param query
     * @return
     * @see #setAlternatenames(String) and {@link #setAlternatenamesSafe(String)}
     */
    public static String removeSurrogatesFromCSV(String query) 
    {
       String parts[] = query.split(",");
    String sep = "";
    StringBuilder sb = new StringBuilder();
    for (String part:parts)
        {
        sb.append(sep);
        part = StringUtils.trimToEmpty(removeSurrogates(part,false)); 
        if (!part.isEmpty()) 
            {
            sb.append(part);
            sep=",";
            }
        }
        
        
       return sb.toString();
    }
    /**
     * I am facing a situation where i get Surrogate characters in text that i am saving to MySql 5.1. As the UTF-16 is not supported in this, I want to remove these surrogate pairs manually by a java method before saving it to the database.
     * http://stackoverflow.com/questions/12867000/how-to-remove-surrogate-characters-in-java
     * @param query
     * @return
     */
    public static String removeSurrogates(String query) 
    {
        return removeSurrogates(query,false); 

    }
    /**
     * I am facing a situation where i get Surrogate characters in text that i am saving to MySql 5.1. As the UTF-16 is not supported in this, I want to remove these surrogate pairs manually by a java method before saving it to the database.
     * http://stackoverflow.com/questions/12867000/how-to-remove-surrogate-characters-in-java
     * @param query
     * @param preserveLength if true then the surrogates are turned into '[]'.
     * @return
     */
    public static String removeSurrogates(String query,boolean preserveLength) 
        {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < query.length(); i++) {
            char ch = query.charAt(i);
            if (Character.isHighSurrogate(ch))
                {
                if (preserveLength) sb.append("[]");
                i++;//skip the next char is it's supposed to be low surrogate
                }
            else
                sb.append(ch);
        }    
        return sb.toString();
        }

Hope this helps!

See:



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
 

Monday, 21 October 2013

Something done in my down time: "Allrangecombat.co.uk"

Allrangecombat Website
I have been a long term student of martial arts and when ask by my senior instructor whether there anything I could do to assist with his website, of course I said yes.

The site is available at allrangecombat.co.uk and allrangecombat.com and has been hosted on a relatively cheep host iPage.
The whole site took about two days to put together and much of that was messing about unnecessarily with uploading content.
The site is based on a nice little CMS called MODX which is 100% PHP which is installable as a standard extra on iPage. While the CSS is based on MetroUI which attempts to emulate Windows Eight's look and feel. I have used it here to provide a CSS which adapts to mobile devices.

Naturally I have attached my own club site to this one as a mini-site: allrangecombat.co.uk/bath.
Enjoy!
Better still come training!

A blatant appeal for work!

Thursday, 5 September 2013

Cool tip of the day: Maven & Eclipse ... importing projects

Today I attempted to import a project that had been written using MAVEN as its build process.
So I confidently when to the eclipse option to import existing maven projects ... all went well until I opened the project & tried to build it. when I saw this error:

Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources (execution: default-resources, phase: process-resources)   pom.xml /test line 6    Maven Project Build Lifecycle Mapping Problem
This was not very welcome and the eclipse autofix options did not fix the issue.
So I turned to Slastdot & found a post (http://stackoverflow.com/questions/7638562/import-maven-project-to-eclipse-and-fix-the-errors) but the top solution to to do a project update did not work.

So to fix it I followed a secondary solution (after deleting the .project file previously created) ...


  1. Open the project folder in a command prompt;
  2. run command mvn eclipse:eclipse
  3. Open the project using eclipse;
  4. Set project properties "configure-->Convert to Maven Project"
My experience is that this works nicely.... ALMOST!

The issue is that eclipse may not correctly pick up the maven dependencies.
This is because the .classpath file does not include values on the paths as  follows "<attribute name="maven.pomderived" value="true"/>".

This for a simple project means that you needs to convert your .classpath file from this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
  <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
  <classpathentry kind="output" path="target/classes"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
</classpath>

to this:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
  <classpathentry kind="src" path="src/main/java" including="**/*.java">
        <attributes>
            <attribute name="optional" value="true"/>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
  <classpathentry kind="output" path="target/classes"/>
      <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
      <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
    </classpathentry>
</classpath>

Now this should pick up your MAVEN dependencies.

Other references:

  1. http://stackoverflow.com/questions/2037188/how-to-configure-eclipse-build-path-to-use-maven-dependencies
  2. https://groups.google.com/forum/#!topic/scala-ide-user/M9pMpZGD624

Cool tip of the day: Formatting source code for your blog

Oh finally!
I have pasted code into my blog & it has been a real pain to get it right.
While looking around I found a resource on blogspot http://formatmysourcecode.blogspot.co.uk/ which provides an online utility to format the script into html to include on your blog.
It has two outputs, one with inline CSS and the other with a set of styles used.
The "linked style sheet" option depends on a PRE.source-code style.

An example of this formatting is as follows:

/**
 * The HelloWorldApp class implements an application that
 * simply prints "Hello World!" to standard output.
 */
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}

A second resource can be found at http://codeformatter.blogspot.co.uk/ which has similar options  but allows you to define whether you have line numbers on your code. When you don't use embedded styles it creates a style element which defines two classes pre.CICodeFormatter and code.CICodeFormatter.

An example of this output is as follow:

1:  /**  
2:   * The HelloWorldApp class implements an application that  
3:   * simply prints "Hello World!" to standard output.  
4:   */  
5:  class HelloWorldApp {  
6:    public static void main(String[] args) {  
7:      System.out.println("Hello World!"); // Display the string.  
8:    }  
9:  }  

A third which I have yet to check is "How to use PrettyPrint to format source code in Blogger" which is a utility on blogger.com which is where this site is.
But more on this an other day.

Saturday, 31 August 2013

Transitioning from ANT to MAVEN

Well I have been putting together ANT scripts for some time now and I have created some funky scripts.
My main issue with ANT was that I had to do all the hard work over and over again. I did work to include IVY into my projects but it was just hard work and the scripts grew in complexity.
I had heard good things about MAVEN so I thought I might as well get stuck into it.

After some successes I smacked straight into an issue regarding the precompilation of JSPs which seems to be a dead topic as the plugins do not seem to work correctly or only work if you are building a WAR.
I want to precompile some JSPs and put them into a JAR ... but no joy.
So right now I am looking back at the ANT scripts and looking how best to include them in to MAVEN.

The first clue was a post on Slashdot titled "Multiple antrun tasks in maven".

The key is to have a series of ANTRuns stuck into your MAVEN script as follows:
<plugin>

    <artifactId>maven-antrun-plugin</artifactId>
    <executions>

        <execution>
            <id>clean</id>
            <phase>clean</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>clean"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

        <execution>
            <id>compile</id>
            <phase>compile</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>compile"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

        <execution>
            <id>package</id>
            <phase>package</phase>
            <configuration>
                <tasks>
                    <echo message = ">>>>>>>>>>>>>>>>>>>>>>>>>>>>package"/>
                </tasks>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>

    </executions>

</plugin>
asas

Friday, 26 July 2013

Debug Java applications remotely with Eclipse

The screens in eclipse
You don't need to debug Java™ applications on just your local desktop.
Remote debugging can be useful for application development, such as developing a program for a low-end machine that cannot host the development platform, or debugging programs on dedicated machines like Web servers, whose services cannot be shut down. Other examples include Java applications running with limited memory or CPU power, such as mobile devices, or developers wanting to separate the application and development environments, etc.

Full article: http://www.ibm.com/developerworks/opensource/library/os-eclipse-javadebug/index.html 

If you don't have it already, download Eclipse V3.4 (Ganymede). In Ganymede, the socket listening connector has been added to the Remote Java Application launch-configuration type. Eclipse's new socket listening connector allows you to start the Java debugger, which listens for a connection on a specific socket. The program being debugged can then be started with command-line options to connect to the debugger. Prior to the Ganymede release, only a socket-attaching connector was provided, and the program being debugged had to be a debug host that was connected by the debugger. It is impractical for mobile devices to be a host due to insufficient memory and CPU power.

The Java Debug Wire Protocol (JDWP) contains many arguments that have been added to invoke the application for the remote Java application. Following are some of the arguments used in this article.
-Xdebug
Enables debugging features.
-Xrunjdwp:<sub-options>
Loads the implementation of JDWP in the target VM. It uses a transport and the JDWP protocol to communicate with a separate debugger application. Specific suboptions are described below.
Starting from Java V5, you can use the -agentlib:jdwp option, instead of -Xdebug and -Xrunjdwp. But if you have to connect to the VM prior to V5, -Xdebug and -Xrunjdwp will be the only choice. Following are brief descriptions of the -Xrunjdwp suboptions.
transport
Generally, socket transport is used. But shared-memory transport can also be used on the Windows platform, if available.
server
If the value is y, the target application listens for a debugger application to attach. Otherwise, it attaches to a debugger application at the specified address.
address
This is the transport address for the connection. If the server is n, attempt to attach to a debugger application at this address. Otherwise, listen for a connection at this port.
suspend
If the value is y, the target VM will be suspended until the debugger application connects. 
This is ideal for setting up remote debugging for eclipse.
The typical settings would be "-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n".

This article lists some nice options for remote debugging a Liferay portal.
http://holisticsecurity.wordpress.com/tag/eclipse/
Enjoy. 

PS.

Friday, 5 July 2013

Cool tool of the day: vLetter

Vletter is a nice way to create handwritten text quickly.

As they say on their site:

We create your own handwriting fontto use on your computer. vLetter captures the natural variations in your handwriting to give your letters, cards and other correspondence a unique, personal touch. Your handwriting font also includes your signature, so you can sign documents and letters with ease. We've been creating personal handwriting fonts since 1988!
Any way its kinda fun ...

Cheers

Friday, 21 June 2013

Setting up Eclipse check list (Part 1)

I find my self due to a major laptop Snafu setting up eclipse from scratch (again) so I thought I would document the stages.

Download Eclipse IDE

You need the IDE for java developers and the latest version can be found here: http://www.eclipse.org/downloads/.
Once it is downloaded upzip it to a target folder.
For this install it will be "C:\development\java\eclipse\indigo". What ever you do don't include any spaces in the path as certain java tools don't like it.
I have also named it with the version so I can install others later.
Set your self up a windows short cut to avoid hunting for it later.

Edit the Eclipse.ini to optimise settings

While eclipse should run straight out of the box (unless you download the 32bit one and are running on a 64 bit system).
Before modifying the eclipse.ini file please back it up. The ini file can be error prone with returns and spaces.

I have an other post which will detail some of the settings you need but they boil down to these:

-vmargs
-Xverify:none
This will tell the VM not to validated all the .class files it is loading.
-vm
<Path to JDK>/jre/bin/server/jvm.dll
Aledgedly Eclipse runs better when linked to a specific dll.
A desirable side effect of this is that if there are any problems with Ports the fire wall will now report "Eclipse" is requesting to access ... sooner than "Java".
Please note the new line after the -vm param.
-vmargs
-Xms128m
-Xmx2048m
Give your self some more memory space. Particularly if you have plenty of memory on your PC.
-vmargs
-Dosgi.requiredJavaVersion = 1.6
Tell Eclipse that it can use the latest version of Java.
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:+AggressiveHeap
-XX:+AggressiveOpts
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=2
-XX:ThreadPriorityPolicy=1
This is an alternate option to setting up the size of memory by hand and these options do not work with -Xms and -Xmx.
They work as follows:
  • The -XX:+AggressiveHeap option inspects the machine resources (size of memory and number of processors) and attempts to set various parameters to be optimal for long-running, memory allocation-intensive jobs. It was originally intended for machines with large amounts of memory and a large number of CPUs, but in the J2SE platform, version 1.4.1 and later it has shown itself to be useful even on four processor machines.
  • A feature available with the throughput collector in the J2SE platform, version 1.4.1 and later releases is the use of adaptive sizing (-XX:+UseAdaptiveSizePolicy), which is on by default. Adaptive sizing keeps statistics about garbage collection times, allocation rates, and the free space in the heap after a collection. These statistics are used to make decisions regarding changes to the sizes of the young generation and tenured generation so as to best fit the behavior of the application. Use the command line option -verbose:gc to see the resulting sizes of the heap.
  • UseParallelOldGC
    Use the Parallel Old garbage collector, This flag enables a parallel version of both the young- and old-generation collectors.
    "UseParallelGC" Use the Parallel Scavenge garbage collector which only enables a parallel collector for the young generation and keeps a serial collector for the old generation.  A serial collector is a single-threaded collector, while the parallel collector that we are enabling can use multiple threads to collect garbage.
    -XX:+UseParallelOldGC is preferred for newer Java releases.
  • -XX:+AggressiveOpts Turns on point performance optimizations.
    Note: this option is experimental! The specific optimizations enabled by this option can change from release to release and even build to build. You should reevaluate the effects of this option with prior to deploying a new release of Java.
  • -XX:ParallelGCThreads=2 Number of parallel threads parallel gc will use. If too more ParallelGCThreads are specified than CPU cores where the JVM is running, this can cause bottlenecks.
    I have 4 cores (:P) so I'm going to use two to prevent it grabbing every thing.
  • -XX:ThreadPriorityPolicy=1
    As 0 = Normal and 1 = Aggressive.
    On Linux thread priorities are ignored because the OS does not support static priority but on windows it works.
    This policy should be used with care, as sometimes it can cause performance degradation in the application and/or the entire system. However, with ThreadPriorityPolicy=0, VM will not use the highest possible" native priority,


Eclipse Preferences
  • Windows -> Preferences; General --> [x] Show heap status.The best way to monitor the current memory useage in Eclipse is to enable HEAP monitoring:

  • Windows -> Preferences; General -> Appearance -> Label Decorations
    disabling label decorations you don't need;
  • Windows -> Preferences; General -> Startup and ShutdownGet rid of "Usage data gathering", "Equinox ...", "Mylyn..>", "Market Place client".
  • Windows -> Preferences;  MavenTurn off all un needed options on the first Maven tab (all?)
  • Windows -> Preferences;Mylyn --> TasksTurn of sysncronization;

At this point Eclipse should run like lightning.
The next thing to do is to start adding in your plugins.
This is the topic of the next post.

So for reference my eclipse.ini looks like this:

-vm
C:/development/tools/Java/jdk1.7.0_17/jre/bin/server/jvm.dll
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.7
-XX:+AggressiveHeap
-XX:+AggressiveOpts
-XX:+UseParallelOldGC
-XX:ParallelGCThreads=2
-XX:ThreadPriorityPolicy=1
-Xverify:none




See: http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html



(Next>>)

Friday, 7 June 2013

Oh why didn't I ask these questions at my interview!

There are times when you are in an interview and you are ask "Do you have any questions for us?".
On many occasions I thought I had interesting and insightful questions which would help me get the job (ps this works the other way round too).
However I should have been asking the 12 questions from the Joel test as they are the ones that really matter to developers.
In case you are not sure what they are let me reproduce them here:
The Joel Test
  1. Do you use source control?
  2. Can you make a build in one step?
  3. Do you make daily builds?
  4. Do you have a bug database?
  5. Do you fix bugs before writing new code?
  6. Do you have an up-to-date schedule?
  7. Do you have a spec?
  8. Do programmers have quiet working conditions?
  9. Do you use the best tools money can buy?
  10. Do you have testers?
  11. Do new candidates write code during their interview?
  12. Do you do hallway usability testing?
As you can see they are pretty good ... go to Joel test and read the definitions or just ask how much your company scores.
The company I am currently working for only scores 3/12 on the Joel test and that is because I  am being generous.

There is a new version of the Joel test because it is 10 years old and things move on in that time.
This new version can be found here (http://geekswithblogs.net/btudor/archive/2009/06/16/132842.aspx).

The Joel Test

  1. Do you have a change management system?
    There needs to be a configuration management plan, control of assets beyond “source code”, branching and merging strategy (even if it’s not to branch), release stabilization and deployment plan, security permissions and roles, quality gates for checking and/or merge, etc. Otherwise, “use source control” is just referring to a glorified backup system. 
  2. Can everyone make a build in one step? Individual developers need access to the automated build system. The official nightly build can “build everything”, but developers need to be able to build individual parts, pull together the required assets, and run from a representative staging area – maybe a virtual machine (or two), a network share, or just a folder on disk. 
  3. Do your daily build include automated tests? It’s not enough to just build – we need an indication of build quality. “Break the build” should mean more than “does not compile”, it should also mean “does not pass the tests”. 
  4. Is work item tracking integrated with source control? What artifacts were changed with a given bug fix? What bug or development task is associated with the most recent change-set? Which bugs are associated with a given merge? Check-outs (or commits, depending on the source control system in use), must be associated with bug reports or development tasks. Each check-in should reflect changes for one task (unless they are coupled tasks). You should also be able to query, based on a bug report, which artifacts were changed (or ideally, currently in the process of being changed). In other words, change management must be integrated with bug tracking and project task tracking. 
  5. Do you fix bugs and write new code?A properly run project will have a branching / merging strategy (or tagging/labeling policy) that allows simultaneous bug fixes with new development. A quality organization will be able to correct bugs in previous releases, and ensure those corrections are in the current release. Without copying or duplicating the code base.
  6. Do you track progress and manage change?
    Project tracking must include processes that allow for managing (planning / executing / tracking) change as well as tracking progress and periodic re-planning of the remaining work. 
  7. Do you have a requirements management system? The “spec” will change; that change needs to be managed. Too often I see organizations with an excellent process for development of the “spec” and a horrible process for managing change in the spec. Note: In 2010, if you don’t have a “spec”, you automatically get a ZERO on the new Joel Test and there is no point in continuing on. 
  8. Do programmers have quiet working conditions and teaming rooms? The teaming rooms are more than a room with a white-board. There is a conference phone, computers (more than one), projector, and lots of white boards. Code reviews, code walk-through, mentoring, design, dispute resolution, meeting with customers – can all take place here. 
  9. Do you use the best tools money can buy or the latest open source tools?
    No change needed. This one is timeless but with a minor tweek.
  10. Are your testers involved in requirements management? The test team needs to be involved in the requirements management system as well as the product validation process. Tests are executed against the requirements. The testers should have authority to approve/reject a deployment as well as approve or reject a requirement. Otherwise, they’re just testers. 
  11. Do new candidates review code during their interview? “Writing code” is one thing – understanding code is another. Candidates should be able to answer questions like “is this code thread-safe?”, “is the code well-commented?”, or “Is the implementation appropriate” – and why. Printing fizz-buzz is one thing; being able to appropriately critique a page of code is another. As a bonus, you could always ask them to re-write it and get the best of both.
    Or you could throw a random biut of open source at them and ask them to explain it.
  12. Do you do hallway usability testing? No change there.
On this scale my new job scores 0/12.

Oh Crap!

Tuesday, 14 May 2013

Cool tooltip of the day: Log4e




There are times when you find a class in your code base which some Muppet has created a class file which  is full of logging to System.out sooner than Log4j.

Well don't panic!

Using Log4E you can re-factor your class in an instance to use Log4j ... and your problem goes away.

To install see: http://log4e.jayefem.de/content/view/3/2/ and install the free or the Pro version.

See: Previous post

Tuesday, 9 April 2013

Cool Tip of the day - An online barcode generator

A 2-d barcode for this site.
If you want one of those neat little 2-d barcodes for your web site or project, then pop over to http://www.barcode-generator.org/.

It includes many of the most popular formats for barcodes, including QR codes as seen on this page; 2-d data matrices and EAN which appears on most retail products.

Wednesday, 20 March 2013

Cool tool tip of the day: Rant and Rave

Gathering customer feed back can assist and drive sales.
According to Rapide Communications who produce the "RantandRave" product:

"The most important aspect of capturing feedback is timing. Response rates increase 10% to 12% and accuracy increases by 40% simply by requesting feedback straight after service delivery."


I interviewed with these guys and from the research I did their product sounds very useful.

http://rantandrave.com/feedback/capturing-customer-feedback/

Tuesday, 19 March 2013

Cool tip of the day: Don't trust SSL

How good is SSL?

Not so great according to HAK5.org.
http://www.youtube.com/watch?v=PmtkJKHFX5Q

The key point on this video is don't be a n00b!
Check for real https and use SSH tunneling!

Friday, 15 March 2013

Cool tip of the day: Ebuild

EBuild is an ant based generic build system for Java projects developed in Eclipse.

it can build almost any Eclipse java project with very minimal configuration.
it automatically figures out dependencies and build order based on the .classpath Eclipse files.

http://ebuild.firefang.net/

The project is about 5 years old and hasn't been under development for some time (not that it needs it).
I am currently working on this project with its creator to add a couple of new features. (watch this space) 

Project on Sourceforge: A generic ANT build script. http://sourceforge.net/projects/antbuildscript/


All you java developers ... do you find your self looking to create a build script to package up your beautiful code?
No?
Are you sure you are a developer?
I was packing up my other project (Beanmapper) and I though this might be handy to other people.

project on source forge: http://sourceforge.net/projects/antbuildscript/

However you really can't use this project with out using : ebuild a cute ant tool.

Cool tip of the day - Bitnami Stacks

When you need a LAMP stack or a Tomcat Stack for development ... what do you do?

Yes you go trawling around the net looking for all the bits and how to glue them together.
Well don't just go to http://bitnami.org/stacks and download their all in one stack.

My favorite is the tomcat stack!

Cool tip of the day - Newrelic server and app monitoring

 This looks worth an invertigate if you have some servers to watch: https://newrelic.com/

They say on their web site that they do the following:
New Relic is the all-in-one web application performance tool that lets you see performance from the end user experience, through servers, and down to the line of application code.

They seem to have the free try before you buy option while their full price offering is $24 per month. This could be considered expensive for some uses especially as it seems to be offering much that Google analytics also offers.

But one to think about nether the less.

Tuesday, 12 March 2013

Quick Guide to setting up Tomcat on Linux

Tomcat's default website

Before starting

Check for the process:


# ps ax | grep tomcat

If it is installed it will show up in the response (don't be fooled by just grep tomcat).

And check the OS (see):
$ cat /etc/*-release
$ uname -m

This will tell you the release and whether it is 64 or 32 bit.

Install the Java JDK

Versions of Java can be installed using the “yum” tool (this will require super user rights). 
See: http://wiki.centos.org/HowTos/JavaOnCentOS


When installed I find that a convenience symbolic link "/java" is helpful.
Often the Yum tool places the files here /usr/lib/jvm/java-6-oracle
NB.
ln -s [TARGET DIRECTORY OR FILE] ./[SHORTCUT]

You can download the latest JDK here: http://www.oracle.com/technetwork/java/javase/downloads/index.html
The problem with this site is that it asks for you to accept the license conditions before you can down load the file.
This can be done by checking the url you get after browsing the appropriate links (see but best done using firefox not IE).

We'll install the latest JDK, which is JDK 7, Update 17. The JDK is specific to 32 and 64 bit versions.

My CentOS box is 64 bit, so I'll need: jdk-7u17-linux-x64.tar.gz.

If you are on 32 bit, you'll need: jdk-7u17-linux-i586.tar.gz
ie.

wget http://download.oracle.com/otn-pub/java/jdk/7u17-b02/jdk-7u17-linux-i586.tar.gz

NB. I'm not sure this works at all so I used WinSCP and transferred the file.

Start by creating a new directory /usr/java: (# mkdir /usr/java).
Download the appropriate JDK and save it to /usr/java directory we created above.

Unpack jdk-7u17-linux-x64.tar.gz in the /usr/java directory using tar -xzf:
tar -xzf jdk-7u17-linux-x64.tar.gz  

DON'T FORGET!!! 
... Set JAVA_HOME and put Java into the path of our user!

JAVA_HOME=/usr/java/jdk1.7.0_17
export JAVA_HOME 
PATH=$JAVA_HOME/bin:$PATH 
export PATH 
   
NB. The export command will marks each VAR for automatic export to the environment of subsequently executed commands i.e. make the local shell variable VAR global. (see)

Check you did it correctly:

#echo $JAVA_HOME 
#java -version

One GOTCHA at this point can be the error "-bash: /usr/java/jdk1.7.0_17/bin/java: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory"

This is easy to fix (see here) by issuing this command:
yum -y install glibc.i686
 

Download & Install Tomcat

If necessary versions of Tomcat can be installed by hand or using “yum”.

Details on Tomcat can be found here: http://tomcat.apache.org/ or more specifically: http://tomcat.apache.org/tomcat-7.0-doc/index.html.

We can manually do this as follows (installing Tomcat 7 under /usr/share.).
Download and unzip.

# wget http://mirror.ox.ac.uk/sites/rsync.apache.org/tomcat/tomcat-7/v7.0.37/bin/apache-tomcat-7.0.37.tar.gz
# tar -xzf apache-tomcat-7.0.29.tar.gz

 From this point you should be able to start the process by jumping to /user/share/apache-tomcat-7.0.37/bin and running the start.sh

For more information on starting as a service : see http://www.davidghedini.com/pg/entry/install_tomcat_7_on_centos

NB. I haven't gone into the details of tidying up the service with symbolic links (an exercise for the reader and me to tidy up in future.) 

To check the process is working then the following operation will work:

#curl -I http://localhost:8080