May 25 2011

Remote Debug

Inorder to keep my sanity I am proposing to myself to write a blog that reminds myself how to remote debug. I can’t believe that this is the one things I always forget how to do. So here it is… For the love of all things good please remember that if you want to remote debug an application server just simply add the below line to the start up java options:

set JAVA_OPTIONS_DEBUG=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=5005,suspend=n,server=y


May 24 2011

Friend of Eclipse Foundation

I just became a friend of eclipse. If you use it please donate to the project. While open source is good, the only projects worth supporting are the projects with financial backing. I think this greatly increases the quality of the opensource product.


Apr 2 2011

New Venture Part 1

My challenge to myself is to create a social website that is useful to others. Now I have this theory that people don’t come up with brilliant ideas they actually just persevere and keep at an idea until it is complete. This is my thought on the matter as you hear people speak  about great ideas, but these ideas come from people who just think about them and do not actually implement them. This is a sad tragedy of human behaviour. If everyone had to follow through on their ideas imagine the possibilities. So this is why I have set up this challenge, its not to show off my programming or lack of programming skills :-) . But rather to show that if you stick at an idea you can finish and publish a website. Enough of doing this may lead to rewards down the line but for now it is just to prove that I can finish a site.

So in order to accomplish this I need a few parameters:

1. Budget: R5000-00.

Well that is actually all the parameters, as I already have the skills (I hope), tools and idea I need to develop this social site.

Now to create the site I need a few things to be done:

1. Register a domain name: I have registered turus.me, which apparently is Scottish Gaelic for journey. This is fitting as this is a jouney I am taking inorder to show that development is not the hard part, sticking to one idea and following through is the hard part.

2. Get a server: I am going to use GoDaddy.com windows virtual server basic. There is no reason for this other than the price is within my budget. R5000-00 for all those who don’t know, can’t buy much. This is less than the amount that was given to facebook initially in the dorm room used to purchase the first server (well according to the movie).

3. Create the site: I am going to create the site in java using a toolset as follows. The spring framework, hibernate, tomcat 7 and mysql. These are the technologies I am comfortable with at the moment and will result in a rapidly developed site. I am not saying they are the absolute best choices, but the are all well supported in the community and the documentation is not bad.

4. Create mobile apps: I will only create mobile applications for the blackberry, android and windows phone 7 environments purely because I do not want to buy a mac just to develop an application for the iphone. But I think the coverage of smart phone devices is decent even though the iphone users are the most likely to download an application.  

Well this is the challenge I am setting myself. I hope it works out, otherwise I just spent a few hours wasting my time writing this blog. If any developers are willing to help please let me know. I can turn over a percentage of the site for development time. Who knows it might actually make some money. But moving along I think this can be up and running in the next 3 months, 3 months is a long time as I have a full time job, another new venture, masters and gym to do in between. Now that I put it on paper it sounds a bit to ambitious. I will try anyway, hope it goes well.

My word, I can’t believe wordpress actually saved this post.


Mar 23 2011

Its not that hard

This post is a bit of a rant. A release valve of sorts that will allow me to express my dissappointment in the human civilization to admit that what they do in general is not that hard. To set the context, I am talking about corporate South Africa, but I am sure there similarities in other civilizations though!

I am a software engineer by profession or “programmer”, well software engineering is not an official profession. Now I know that the average programmer is confident and arrogant and we all think we can change the world. Yes some of us can, but it is not due to the skill of programming it is due to the idea that we can change the world, programming is just a trivial task that is a tool we use in our attempt at changing the world. Now that may hurt a few egos or not, I am not going to say that people actually read this blog, but then again it is a personal venture of mine and in all I feel better just putting some things out there. So anyway lets face it, programming is not hard! In this day and age the hard work is done for us. Now enough about programming, why are there so many professionals from doctors to engineers that think what they do is so hard? Is it really or is it that they are the people in the position at the time. I think the idea of original though is hard, learning is not, original thought is.

So this makes me ask, what leads to a person being perceived as smart? I have a feeling its a matter of learning capacity and patience, nothing else…… These are not all my thoughts just a rant in a frustrated mood. And sorry for the spelling mistakes if any…


Mar 10 2011

A Blackberry UiApplication Phase 1

I have been playing around with blackberry development for a while now. During this time I have noticed a common pattern of how a gui project should look. This is my attempt on creating a shell for all gui projects, called skeleton. Just keep in mind that this will change over time as this was done in about an hour, so it does not contain every component that would constitute a complete shell yet. But it is a start.

Before I start I am developing on windows using the eclipse development environment for eclipse.

Firstly, I created a standard project using the eclipse ide with 3classes and a few added folders (models, img and icon all in the root folder):

1. MainEntry.java


package me.bayes.skeleton;

import me.bayes.skeleton.gui.FrontScreen;
import me.bayes.skeleton.gui.SplashScreen;
import net.rim.device.api.ui.UiApplication;

/**
 * This is the mail entry point of the application.
 *
 * @author Kevin Bayes
 *
 */
public final class MainEntry extends UiApplication {

	public MainEntry() {
		FrontScreen frontScreen = new FrontScreen();
		new SplashScreen(this, frontScreen);
	}

	public static void main(String[] args) {
		MainEntry entry = new MainEntry();
		entry.enterEventDispatcher();
	}

}

2. FrontScreen.java – The front screen will be the landing page once you have exited the splash screen. As part of this and I have added a sample of using preprocessing to cater for multiple devices.


//#preprocess

package me.bayes.skeleton.gui;

import net.rim.device.api.ui.component.TextField;
import net.rim.device.api.ui.container.MainScreen;

/**
 * Currently this is empty, but it does show the usefulness of preprocess
 * @author Kevin Bayes
 *
 */
public final class FrontScreen extends MainScreen {

	public FrontScreen() {
		super();

		TextField text = new TextField();
		//#ifdef RIM_6.0.0
		text.setText("It's 6.0.0");
		//#else
		text.setText("Not 6.0.0");
		//#endif
		add(text);
	}

}

3. SplashScreen.java – The splash screen is the introduction to your application and can be used to mask the booting up of your application. Here preprocessing has not been used as the image that will be loaded will be decided at compile time using an ant build.


package me.bayes.skeleton.gui;

import java.util.Timer;
import java.util.TimerTask;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;

/**
 * @author Kevin Bayes
 *
 */
final public class SplashScreen extends MainScreen {
	private MainScreen next;
	private Timer timer = new Timer();
	private UiApplication application;
	//This splash screen is an image read from the root folder of the application
	private static final Bitmap _bitmap = Bitmap.getBitmapResource("skeleton.png");       

	public SplashScreen(UiApplication ui, MainScreen next) {
		super (Field.USE_ALL_HEIGHT|Field.FIELD_LEFT);
		this.application = ui;
		this.next = next;
		this.add(new BitmapField(_bitmap));
		/*
		 * create a listener to allow the user to exit the splash screen
		 * manually or override the navigation events as done below.
		 *
		 * the splash screen listener should implement net.rim.device.api.system.KeyListener.
		 **/
		//SplashScreenListener listener = new SplashScreenListener(this);
		//this.addKeyListener(listener);
		//create a timer to count down to the splash screens exit
		timer.schedule(new ExitSplashCountDown(), 5000L);
		application.pushScreen (this);
	}
	/**
	 *

When the splash screen exits three things happen

	 *
    *
  1. The timer is canceled. *
  2. You pop the splash screen off the stack. *
  3. You push the main screen onto the stack. *
*/ public void dismiss() { timer.cancel(); application.popScreen (this); application.pushScreen (next); } /** * * This {@link TimerTask} is used to make sure the splash screen exits and * * does not display forever. * * * * @author Kevin Bayes * * */ private final class ExitSplashCountDown extends TimerTask { public void run() { ExitSplashThread dThread = new ExitSplashThread(); application.invokeLater (dThread); } } /** * * Used by the {@link ExitSplashCountDown} to exit the splash screen. * * * * @author Kevin Bayes * * */ private final class ExitSplashThread implements Runnable { public void run() { dismiss(); } /* * * When you click the navigation then the screen should exit and go to your applications main screen * * * * (non-Javadoc) * * @see net.rim.device.api.ui.Screen#navigationClick(int, int) * */ protected boolean navigationClick(int status, int time) { dismiss(); return true; } /* * * Make sure nothing happens when the navigation senses movement * * * * (non-Javadoc) * * @see net.rim.device.api.ui.Screen#navigationMovement(int, int, int, int) */ protected boolean navigationMovement(int dx, int dy, int status, int time) { return false; } /* * * Make sure nothing happens when unclick occurs * * * * (non-Javadoc) * @see net.rim.device.api.ui.Screen#navigationUnclick(int, int) */ protected boolean navigationUnclick(int status, int time) { return false; } } }

If you would like for the sake of development you should fill in the BlackBerry_App_Descriptor.xml and a preprocessing tag of RIM_6.0.0 to test the preprocessing during development. Now once you have completed your development and want to build the application for multiple platforms. To do this I have used the bb-ant-tool. Mu script only includes preprocessing tags and compiling, I will add features like the signing tool at a later stage. Now to buid the skeleton project I created the following ant script:


<project name="Skeleton Project" basedir="." default="build">

	<!-- Default phone is torch -->
	<property file="${basedir}/models/9800.properties" />

	<!-- Give your project title and version (Same as blackberry app descriptor) -->
	<property name="project.title" value="Skeleton"/>
	<property name="project.version" value="1.0.0"/>
	<property name="blackberry.ant.library.location" value="D:/Programming/bb-ant-tools-1.2.11-bin"></property>
	<!-- cdlc means Rimlet -->
	<property name="application.type" value="cldc"></property>
	<!-- set the jde home -->
	<property name="jde.home" value="D:/Programming/ide/eclipse-blackberry/plugins/net.rim.ejde.componentpack6.0.0_6.0.0.29/components" />
	<!-- set the build directory -->
	<property name="build.directory" value="${basedir}/build"></property>

	<!-- create an ant task for blackberry -->
	<taskdef resource="bb-ant-defs.xml" classpath="${blackberry.ant.library.location}/bb-ant-tools.jar"/>

	<target name="clean">
		<description>
			Delete all the previous built projects.
		</description>
		<delete dir="${build.directory}" failonerror="no"></delete>
		<delete file="${jde.home}/simulator/${project.title}_${model}.cod" failonerror="no"/>
	</target>

    <target name="clean-simulator">
    	<description>
    		1. Run the simulators clean file.
    		2. Delete the application from the simulator
    	</description>

        <exec executable="${jde.home}\simulator\clean.bat" dir="${jde.home}\simulator"/>

    	<exec executable="${jde.home}\simulator\fledge.exe" dir="${basedir}\simulator-data">
            <arg value="/app=${jde.home}\simulator\Jvm.dll"/>
            <arg value="/handheld=${model}"/>
            <arg value="/clear-flash"/>
            <arg value="/shutdown-after-startup"/>
        </exec>
   </target>

    <target name="setup">
    	<description>
    		Create a build directory to hold exactly the source
    		and resource files for the selected device model.

    		Then copy all the necesary files.
    	</description>

        <mkdir dir="${build.directory}\img"/>
        <mkdir dir="${build.directory}\res"/>
        <mkdir dir="${build.directory}\src"/>
        <mkdir dir="${build.directory}\${project.title}"/>
        <copy todir="${build.directory}\src">
            <fileset dir="${basedir}\src"/>
        </copy>
        <copy file="${basedir}\icon\${size.icon}\${project.title}_icon.png"
              tofile="${build.directory}\img\${project.title}_icon.png"
        />
        <copy todir="${build.directory}\img">
            <fileset dir="${basedir}\img\${size.screen}"/>
        </copy>
        <copy todir="${build.directory}\res">
            <fileset dir="${basedir}\res"/>
        </copy>
    </target>

	<target name="build" depends="setup">
		<description>
				We are going to compile the project and use the tags for preprocessing.
		</description>
		<rapc destdir="${build.directory}\${project.title}" output="${project.title}"
			              srcdir="${build.directory}">
			<jdp type="${application.type}" title="${project.title}"
			                 icon="../img/${project.title}_icon.png" />
			<define tag="RIM_${rim.version}"/>
			<define tag="SCREEN_${size.screen}"/>
		</rapc>
	</target>

	<target name="deliver" depends="clean, build">
	        <copy file="${build.directory}\${project.title}\${project.title}.cod"
	            tofile="${jde.home}\simulator\${project.title}_${model}.cod"
	        />
	        <copy file="${build.directory}\${project.title}\${project.title}.cod"
	            tofile="${basedir}\delivery\${project.title}_${model}.cod"
	        />

	        <delete dir="${build.directory}"/>
	 </target>

</project>

Now all you need to do is to create multiple property files in the models directory and there you go build away anywhere…. I will complete a more detailed description as I go along but for now I believe this will suffice.

Please comment about anything you would like me to include in the skeleton project.

Skeleton Project Download