I realize that there are similarities between software developers and software managers:
- Developers manage codes, managers manage people;
- Developers resolve bugs in the codes, managers resolve bugs among the people;
- A developer has to make decisions all the time, compromise his solution with different constraints; A manager has to make decision all the time based on people, schedule and budget;
- A professional developer always choose the right framework and right tool for the task, a professional manager choose the right person to do the right thing;
- A professional developer improves his code by keep constantly refactoring and reflection, a professional manager keep improving his team;
- A professional developer always follows the software principles and design patterns to guide his work, deliberately improve his skills, keep finding new tools; A professional manager will follow the agile patterns and other principles and philosophy (ex. The Art Of War) to guide his work, his has the clear picture of his vision, and keep finding the new process to improve the productivity of his team.
But in reality, unfortunately in my career so far I haven't found a manager which I can regard as a professional manager. Most of them I call them "event dispatcher". They care more about passing the command down to developers, focus more on his boss instead of developers, they don't care how developer finish it nor be interested in it. I even could not find his strategy of management. I really want he can show me how he solved a difficult issue creatively and beautifully, just like I saw my coworker solve an issue by using a pattern or a tool, but so far I haven't seen once.
Right now I know the reason why software industry is still primitive, why there are so many unprofessional developers, because most of our managers are unprofessional. If a manger dos not know the principles and rules of software, how can he manage well for his team? If a manager does not care his developer, how can his developer has motivation to become better?
A good manager for a software team just as a good coach for a soccer team. Professional developers do require professional managers.
Monday, June 21, 2010
Thursday, May 27, 2010
LWUIT blackberry ANT script refactored 2
Last time I posted the refactored blackberry build script, today I made some other small improvements:
1. Add a "run" target, support running both blackberry and regular J2ME simulator.
2. Separate the blackberry specific ant targets into aother build script file, make the build file generic and easier to use.
At the beginning I tried to put all the targets in a separate file: bb-build.xml, then import it in the build.xml, but I found the netbeans custom targets like post-init, post-jar are not called, it seems these targets needs to be explicit specified in the build.xml.
I found another solution - embedding the xml snippet in the build.xml using XML entity, based on this link:
for exmaple, like this:
Benefits:
The new refactored build script becomes generic, does not specific to lwuit project, can apply to any blackberry CLDC app.
I attach the full build script here, and you can use them as template for your blackberry build script in your NetBeans project.
1) build.xml
2) bb-build.xml, the blackberry build script snippet
Next Step:
Add a target support debugging blackberry Application inside the NetBeans IDE.
1. Add a "run" target, support running both blackberry and regular J2ME simulator.
<target name="run" depends="init,jar,bb-run,cldc-run">
<target name="cldc-run" unless="do.rapc" >
<nb-run jadfile="${dist.dir}/${dist.jad}"
jarfile="${dist.dir}/${dist.jar}" jadurl="${dist.jad.url}"
device="${platform.device}" platformhome="${platform.home}"
platformtype="${platform.type}"
execmethod="${run.method}"
securitydomain="${evaluated.run.security.domain}"
commandline="${platform.runcommandline}"
classpath="${platform.bootclasspath}:${dist.dir}/${dist.jar}"
cmdoptions="${run.cmd.options}"/>
</target>
<target name="bb-run" depends="copyBBSimulator" if="do.rapc">
<exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${platform.home}/simulator"
executable="${platform.home}/simulator/${platform.device}.bat"
failonerror="true" resolveExecutable="true"/>
</target>
The above code snipplet means, when user press "run" button in NetBeans IDE, if the current configuration is blackberry, then launch the blackberry simulator, else launch the regular J2ME simulator.2. Separate the blackberry specific ant targets into aother build script file, make the build file generic and easier to use.
At the beginning I tried to put all the targets in a separate file: bb-build.xml, then import it in the build.xml, but I found the netbeans custom targets like post-init, post-jar are not called, it seems these targets needs to be explicit specified in the build.xml.
I found another solution - embedding the xml snippet in the build.xml using XML entity, based on this link:
for exmaple, like this:
<!DOCTYPE project [ <!ENTITY bb-common SYSTEM "bb-build.xml"> ]> &bb-common;The above snippet is equivlent of copying the code from bb-build.xml into build.xml.
Benefits:
The new refactored build script becomes generic, does not specific to lwuit project, can apply to any blackberry CLDC app.
I attach the full build script here, and you can use them as template for your blackberry build script in your NetBeans project.
1) build.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE project [ <!ENTITY bb-common SYSTEM "bb-build.xml"> ]> <project name="myApp" default="jar" basedir="."> <description>Builds, tests, and runs the project .</description> <import file="nbproject/build-impl.xml"/> <property name="app.title" value="myApp" /> <property name="app.version" value="1" /> <property name="app.icon" value="/icon.png" /> <property name="app.vendor" value="foo" /> &bb-common; </project>
2) bb-build.xml, the blackberry build script snippet
<target name="post-init">
<available file="${platform.home}/bin/rapc.exe" property="do.rapc" />
<condition property="jpda.port" value="8000">
<isset property="do.rapc">
</isset>
</condition>
</target>
<target name="post-jar" if="do.rapc">
<antcall target="bbbuild" />
</target>
<target name="run" depends="init,jar,bb-run,cldc-run">
</target>
<target name="cldc-run" unless="do.rapc" >
<nb-run jadfile="${dist.dir}/${dist.jad}" jarfile="${dist.dir}/${dist.jar}" jadurl="${dist.jad.url}" device="${platform.device}" platformhome="${platform.home}" platformtype="${platform.type}" execmethod="${run.method}" securitydomain="${evaluated.run.security.domain}" commandline="${platform.runcommandline}" classpath="${platform.bootclasspath}:${dist.dir}/${dist.jar}" cmdoptions="${run.cmd.options}"/>
</target>
<target name="post-clean">
<delete failonerror="false">
<fileset dir="${platform.home}/simulator">
<include name="**/${name}.*">
</include>
</fileset>
</delete>
</target>
<typedef resource="bb-ant-defs.xml" classpath="bb-ant-tools.jar" />
<target name="bbbuild" description="blackberry build" depends="init" if="do.rapc">
<echo message="rapc build, dir=${dist.dir}"></echo>
<mkdir dir="${dist.dir}/bbant" />
<rapc verbose="true" output="${name}" jdehome="${platform.home}" import="${platform.bootclasspath}" destdir="${dist.dir}/bbant/" noconvert="true">
<src>
<fileset file="${dist.dir}/${dist.jar}" />
</src>
<jdp title="${app.title}" vendor="${app.vendor}" version="${app.version}" type="cldc" icon="${app.icon}" >
</jdp>
</rapc>
<!-- sigtool jdehome="C:Program FilesResearch In MotionBlackBerry JDE 4.7.0" codfile="${dist.dir}/bbant/${name}.cod" password="" / -->
<alx destdir="${dist.dir}/bbant" filename="${name}.alx">
<application id="${app.title}">
<codset>
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</codset>
</application>
</alx>
<mkdir dir="${dist.dir}/bbant-final" />
<jadtool input="${dist.dir}/bbant/${dist.jad}" destdir="${dist.dir}/bbant-final">
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</jadtool>
</target>
<target name="copyBBSimulator" if="do.rapc">
<copy todir="${platform.home}/simulator" verbose="true">
<fileset dir="${dist.dir}/bbant">
<include name="*.cod"/>
<include name="*.jad" />
</fileset>
</copy>
</target>
<target name="bb-run" depends="copyBBSimulator" if="do.rapc">
<exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${platform.home}/simulator"
executable="${platform.home}/simulator/${platform.device}.bat"
failonerror="true" resolveExecutable="true"/>
</target>
Next Step:
Add a target support debugging blackberry Application inside the NetBeans IDE.
Tuesday, May 18, 2010
LWUIT BlackBerry ANT script refactored
My last article about using ANT script to build LWUIT blackberry application was intereted by some people, which is encouraging. I spent some time to review the ant script again and made some improvements. Here I posted my updated build script, it is cleaner and easier to use, you can just use it as template, copy and paste it in your NetBeans project by just configure some parameters.
It has following improvements:
<property name="app.title" value="helloLWUIT" />
<property name="app.version" value="1" />
<property name="app.icon" value="/icon.png" />
<property name="app.vendor" value="foo" />
<target name="post-init">
<available file="${platform.home}/bin/rapc.exe" property="do.rapc" />
<condition property="jpda.port" value="8000">
<isset property="do.rapc">
</isset>
</condition>
</target>
<target name="post-jar" if="do.rapc">
<antcall target="bbbuild" />
</target>
<target name="post-clean">
<delete failonerror="false">
<fileset dir="${platform.home}/simulator">
<include name="**/${name}.*">
</include>
</fileset>
</delete>
</target>
<typedef resource="bb-ant-defs.xml" classpath="bb-ant-tools.jar" />
<target name="bbbuild" description="blackberry build" depends="init">
<echo message="rapc build, dir=${dist.dir}"></echo>
<mkdir dir="${dist.dir}/bbant" />
<rapc verbose="true" output="${name}" jdehome="${platform.home}" import="${platform.bootclasspath}" destdir="${dist.dir}/bbant/" noconvert="true">
<src>
<fileset file="${dist.dir}/${dist.jar}" />
</src>
<jdp title="${app.title}" vendor="${app.vendor}" version="${app.version}" type="cldc" icon="${app.icon}" >
</jdp>
</rapc>
<!-- sigtool jdehome="C:Program FilesResearch In MotionBlackBerry JDE 4.7.0" codfile="${dist.dir}/bbant/${name}.cod" password="" / -->
<alx destdir="${dist.dir}/bbant" filename="${name}.alx">
<application id="${app.title}">
<codset>
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</codset>
</application>
</alx>
<mkdir dir="${dist.dir}/bbant-final" />
<jadtool input="${dist.dir}/bbant/${dist.jad}" destdir="${dist.dir}/bbant-final">
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</jadtool>
</target>
<target name="copyBBSimulator" depends="bbbuild" if="do.rapc">
<copy todir="${platform.home}/simulator" verbose="true">
<fileset dir="${dist.dir}/bbant">
<include name="*.cod"/>
<include name="*.jad" />
</fileset>
</copy>
</target>
<target name="bb-run" depends="copyBBSimulator">
<exec os="Windows NT Windows 95 Windows 98 Windows 2000 Windows XP"
dir="${platform.home}/simulator"
executable="${platform.home}/simulator/${platform.device}.bat"
failonerror="true" resolveExecutable="true"/>
</target>
It has following improvements:
- Separate out the customized parameters in the build scriciptThen entire build script only needs following customized parameters: app.title, app.version, app.icon, app.vendor. You only need to configure them with your own application parameters.
- Simplify the build script. In the old build script, you have to use target "copyBBTouchSources" and "copyBBSources" to copy and update the LWUIT library source code into specific folder, then call rapc compiler to build the entire application. But when you investigate a little bit deeper, since NetBeans IDE already generate jar file for you, which already included the preprocessed application and the LWUIT blackbery library class files, why not just pass this jar file to rapc and then generate the cod file? based on this idea, I modified the target "bbbuild" and it works.
- One build script supports both BlackBerry touch and non-touch build. since the build script is simplified and only use jar file to generate cod file,the touch or non-touch specific files are already embedded in the jar file, the build script itself becomes generic. To tested it, I installed JDE 4.5 and JDE 4.7 two different JDE in the NetBeans, and set up 4.5 and 4.7 different configurations in my project, and I found both works.
- Added the ant target "bb-run", which allow you run the application in the blackberry simulator. To make it work, you had better to check the nbproject\project.properties file, if the simualtor device name is configured properly, In JDE 4.7, the device name is 9500, like this:
configs.BlackBerryTouch.platform.device=9500
In 4.5, the device name is 8320, like this:
configs.BlackBerry.platform.device=8320
Update: Sample project
Please click here to download the sample project.
Please click here to download the sample project.
Tuesday, May 4, 2010
Why should managers embrace agile?
When you look at the articles about Agile/Scrum/Lean, they are all about self-organizing, decentralized, democracy, etc.Those are welcomed by the developers but conflict with managers benefit, because our conventional management is about hierarchy, command and control, chasing the power, the manager cares more about how his boss think instead of how his subordinates think. For managers, embracing agile means loosing power, weaken their benefit, that is why manager don't like agile.
On the other hand, agile is about changing, changing means risky, but the managers care more about the stability of their position, their power, they don't have much enthusiasm to make changes.
So we have a conclusion that developer and manager like two different classes, developers like agile because it brings them benefits; managers dislike agile because it will lose managers' benefit. The progress of agile movement is quite similar with the progress of human's democracy movement.
This sounds discouraging, but this is the fact, that will explain why agile has not become mainstream after 10 years of its movement.Then what can we do? Try to educate as many developers as possible, gradually if agile principles are accepted by most people, then it is quite possible to force the managers make changes. This will take time, but please remember that the manager won't truely embrace agile,just like no ruler will truely embrace democracy.
On the other hand, agile is about changing, changing means risky, but the managers care more about the stability of their position, their power, they don't have much enthusiasm to make changes.
So we have a conclusion that developer and manager like two different classes, developers like agile because it brings them benefits; managers dislike agile because it will lose managers' benefit. The progress of agile movement is quite similar with the progress of human's democracy movement.
This sounds discouraging, but this is the fact, that will explain why agile has not become mainstream after 10 years of its movement.Then what can we do? Try to educate as many developers as possible, gradually if agile principles are accepted by most people, then it is quite possible to force the managers make changes. This will take time, but please remember that the manager won't truely embrace agile,just like no ruler will truely embrace democracy.
Saturday, May 1, 2010
ANT build script for LWUIT blackberry application
Update:
This article is more than a year old, now LWUIT project uses a new tool to build BlackBerry application - NetBeans BlackBerry Plugin, please refer my two latest post:
Developing Blackberry application using NetBeans Plugin - part 1, first impression
Developing Blackberry application using NetBeans Plugin - part 2, fixing debug issue
Shai's article about build script for LWUIT in BlackBerry is great, but it has so many errors,I spend two days trying to fix the errors, and finally make it work.
Here I posted my modified ant buil.xml and application source code. The application is very simple, just display a "Hello World" text. Since this article is based on Shai's article, for details such as project set up, configuration and tools installation etc, please check his article.
application source code
HelloLWUITMidlet.java
ANT build script
Note:
This build script is for touch screen build, for non touch sreen build you need to
1.Comment out "bbtouch" property in target "post-init" :
<!-- <available file="${platform.home}/simulator/9500.bat" property="bbtouch"> --> </available>
2.Remove the "copyBBTouchSources" dependency in target "bbbuild".
This article is more than a year old, now LWUIT project uses a new tool to build BlackBerry application - NetBeans BlackBerry Plugin, please refer my two latest post:
Developing Blackberry application using NetBeans Plugin - part 1, first impression
Developing Blackberry application using NetBeans Plugin - part 2, fixing debug issue
Shai's article about build script for LWUIT in BlackBerry is great, but it has so many errors,I spend two days trying to fix the errors, and finally make it work.
Here I posted my modified ant buil.xml and application source code. The application is very simple, just display a "Hello World" text. Since this article is based on Shai's article, for details such as project set up, configuration and tools installation etc, please check his article.
application source code
HelloLWUITMidlet.java
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BorderLayout;
public class HelloLWUITMidlet extends
//#ifdef RIM
net.rim.device.api.ui.UiApplication
//#else
//# javax.microedition.midlet.MIDlet
//#endif
{
public void startApp() {
Display.init(this);
Form f = new Form();
f.setTitle("Hello World");
f.setLayout(new BorderLayout());
f.addComponent("Center",
new Label("I am a Label"));
f.show();
}
//#ifdef BlackBerry
public static void main(String[] argv)
{
new HelloLWUITMidlet().startApp();
}
public void notifyDestroyed()
{
System.exit(0);
}
public void platformRequest(String s) {
net.rim.blackberry.api.browser.Browser.getDefaultSession().displayPage(s);
}
//#endif
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
ANT build script
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<project name="helloLWUIT" default="jar" basedir=".">
<description>Builds, tests, and runs the project .</description>
<import file="nbproject/build-impl.xml"/>
<target name="post-init">
<available file="${platform.home}/bin/rapc.exe" property="do.rapc" />
<available file="${platform.home}/simulator/9500.bat" property="bbtouch" />
<condition property="jpda.port" value="8000">
<isset property="do.rapc">
</isset>
</condition>
</target>
<target name="post-preprocess" depends="copyBBSources,copyBBTouchSources">
</target>
<typedef resource="bb-ant-defs.xml" classpath="bb-ant-tools.jar" />
<target name="bbbuild" description="blackberry build" depends="init,copyBBSources,copyBBTouchSources">
<echo message="Compiling ${preprocessed.dir}"></echo>
<mkdir dir="${dist.dir}/bbant" />
<rapc verbose="true" output="${name}" jdehome="${platform.home}" import="${platform.bootclasspath}" destdir="${dist.dir}/bbant/" noconvert="true">
<src location="${basedir}/${preprocessed.dir}">
</src>
<jdp title="helloLWUIT" version="1" type="cldc" icon="/icon.png" >
</jdp>
</rapc>
<!-- sigtool jdehome="C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0" codfile="${dist.dir}/bbant/${name}.cod" password="" / -->
<alx destdir="${dist.dir}/bbant" filename="${name}.alx">
<application id="helloLWUIT">
<codset>
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</codset>
</application>
</alx>
<mkdir dir="${dist.dir}/bbant-final" />
<jadtool description="desc" id="appId" input="${dist.dir}/bbant/${dist.jad}" destdir="${dist.dir}/bbant-final">
<fileset dir="${dist.dir}/bbant" includes="*.cod">
</fileset>
</jadtool>
</target>
<target name="copyBBTouchSources" if="bbtouch">
<echo message="Copying blackberry touch sources"></echo>
<copydir forceoverwrite="true" src="${project.BlackberryPort}/build/touch/preprocessed" dest="${basedir}/${preprocessed.dir}" />
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/M3G.java" />
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/SVGImage.java" />
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/animations/Transition3D.java" />
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/impl/midp/SVGImplementation.java" />
</target>
<target name="copyBBSources" if="do.rapc">
<echo message="Copying blackberry sources ${preprocessed.dir}"></echo>
<copydir src="${project.LWUIT}/src" dest="${basedir}/${preprocessed.dir}" />
<copydir forceoverwrite="true" src="${project.BlackberryPort}/build/preprocessed" dest="${basedir}/${preprocessed.dir}" />
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/M3G.java"/>
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/SVGImage.java"/>
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/animations/Transition3D.java"/>
<touch file="${basedir}/${preprocessed.dir}/com/sun/lwuit/impl/midp/SVGImplementation.java"/>
</target>
<target name="post-jar" if="do.rapc">
<rapc verbose="true" output="${name}" jdehome="${platform.home}" import="${platform.bootclasspath}" destdir="${platform.home}/simulator/" noconvert="true">
<src location="${basedir}/${preprocessed.dir}">
</src>
<jdp title="helloLWUIT" version="1" type="cldc" icon="/icon.png" >
</jdp>
</rapc>
</target>
<target name="post-clean">
<delete failonerror="false">
<fileset dir="${platform.home}/simulator">
<include name="**/${name}.*">
</include>
</fileset>
</delete>
</target>
</project>
Note:
This build script is for touch screen build, for non touch sreen build you need to
1.Comment out "bbtouch" property in target "post-init" :
<!-- <available file="${platform.home}/simulator/9500.bat" property="bbtouch"> --> </available>
2.Remove the "copyBBTouchSources" dependency in target "bbbuild".
Wednesday, April 21, 2010
Build LWUIT BlackBerry CLDC application
Last week finally I have time to review the Shai's blog about building LWUIT project on Blackberry platform. At first I tried to follow the step by step in his article, but I am disappointed because of so many errors of his build.xml. After a couple hours fix, I still could not make the build, so I decided to give up Shai's script, and choose an easier way.
My solution is just using NetBeans and BlackBerry JDE, it is much easier to build a demo.
Here is the step by step description:
Build LWUIT BlackBerry library
1. Checkout the LWUIT source code from SVN, (https://lwuit.dev.java.net/svn/lwuit/trunk), the LWUIT source includes the NetBeans BlackBerry port project.
2. Install JDE 4.7 and Configure BlackBerry support in NetBeans, you can follow this link to configure;
3. Start NetBeans, open the "BlackBerryPort" poject under the "BlackBerry" sub folder of lwuit project source, there are two configuration for this project, the default is for non touch screen build, the "touch" configuration is for touch screen device like STORM.for non touch device, just choose DefaultConfiguration, build the project, you will see BlackberryPort.jad and BlackberryPort.jar in \dist folder, they are the LWUIT library for BlackBerry devices;
Build LWUIT Demo into BlackBerry CLDC application
1. Open Blackberry JDE, create a new workspace, called "lwuitdemo.jdw";
2. add a new project under the workspace, name it "lwuit", choose its Application type as "Library", import the BlackberryPort.jad and BlackBerryPort.jar file into the project. then build it, the JDE will generate lwuit.cod and update BlackBerryPort.jad file.
3. download LWUIT 1.3 from sun website, it comes with the famous LWUITDemo source code, open the LWUITDemo project using NetBeans, build it;
4. add another new project in the JDE workspace, name it "lwuitdemo", choose application type as "CLDC Application";
set up the correct value with title, version and Vendor information;
next you need to add project dependency to "lwuit" project, right click project, choose "Project Dependencies..", choose "lwuit project";
copy all the java source code from LWUITDemo src folder, add them into the project, ignore those png files and .res files;
go to build\preverified folder, copy all the png files and .res files, add them into your JDE project;
right click icon.png, choose "use as application icon";
5.Modify the UIDemoMIDlet.java
Made following changes:
make sure the UIDemoMIDlet extends from uiApplication, like this:
7. Sign both lwuitdemo.cod and lwuit.cod fle, load them both into your blackberry device.
8. If you want to provide OTA download, that is a litttle bit tricky:
You need to download two artifacts, one for lwuit libray, the other for lwuitdemo, which means user need to download two links:
1) lwuti library:
BlackBerryPort.jad
lwuit.cod
lwuit-1.cod
...
2) lwuitdemo application:
lwuitdemo.jad
lwuitdemo.cod
lwuitdemo-1.cod
...
You can download the whole source code of the JDE project from here.
In future I would like to share:
1. Provide an updated build.xml based on Shai's blog;
2. provide how to build LWUITDemo MIDlet project for BlackBerry device.
My solution is just using NetBeans and BlackBerry JDE, it is much easier to build a demo.
Here is the step by step description:
Build LWUIT BlackBerry library
1. Checkout the LWUIT source code from SVN, (https://lwuit.dev.java.net/svn/lwuit/trunk), the LWUIT source includes the NetBeans BlackBerry port project.
2. Install JDE 4.7 and Configure BlackBerry support in NetBeans, you can follow this link to configure;
3. Start NetBeans, open the "BlackBerryPort" poject under the "BlackBerry" sub folder of lwuit project source, there are two configuration for this project, the default is for non touch screen build, the "touch" configuration is for touch screen device like STORM.for non touch device, just choose DefaultConfiguration, build the project, you will see BlackberryPort.jad and BlackberryPort.jar in \dist folder, they are the LWUIT library for BlackBerry devices;
Build LWUIT Demo into BlackBerry CLDC application
1. Open Blackberry JDE, create a new workspace, called "lwuitdemo.jdw";
2. add a new project under the workspace, name it "lwuit", choose its Application type as "Library", import the BlackberryPort.jad and BlackBerryPort.jar file into the project. then build it, the JDE will generate lwuit.cod and update BlackBerryPort.jad file.
3. download LWUIT 1.3 from sun website, it comes with the famous LWUITDemo source code, open the LWUITDemo project using NetBeans, build it;
4. add another new project in the JDE workspace, name it "lwuitdemo", choose application type as "CLDC Application";
set up the correct value with title, version and Vendor information;
next you need to add project dependency to "lwuit" project, right click project, choose "Project Dependencies..", choose "lwuit project";
copy all the java source code from LWUITDemo src folder, add them into the project, ignore those png files and .res files;
go to build\preverified folder, copy all the png files and .res files, add them into your JDE project;
right click icon.png, choose "use as application icon";
5.Modify the UIDemoMIDlet.java
Made following changes:
make sure the UIDemoMIDlet extends from uiApplication, like this:
public class UIDemoMIDlet extends net.rim.device.api.ui.UiApplication {...}
Add the following methods, copied from Shai's blog:public static void main(String[] argv)
{
new UIDemoMIDlet().startApp();
}
public void notifyDestroyed()
{
System.exit(0);
}
public void platformRequest(String s) {
net.rim.blackberry.api.browser.Browser.getDefaultSession().displayPage(s);
}
In startApp() method, comment out the following statement, because non touch device need to disable the virtual keypad:// VKBImplementationFactory.init();6. Build the lwuitdemo project.
7. Sign both lwuitdemo.cod and lwuit.cod fle, load them both into your blackberry device.
8. If you want to provide OTA download, that is a litttle bit tricky:
You need to download two artifacts, one for lwuit libray, the other for lwuitdemo, which means user need to download two links:
1) lwuti library:
BlackBerryPort.jad
lwuit.cod
lwuit-1.cod
...
2) lwuitdemo application:
lwuitdemo.jad
lwuitdemo.cod
lwuitdemo-1.cod
...
You can download the whole source code of the JDE project from here.
In future I would like to share:
1. Provide an updated build.xml based on Shai's blog;
2. provide how to build LWUITDemo MIDlet project for BlackBerry device.
Thursday, April 8, 2010
How to send email in BlackBerry Simulator
Recently I am working on a BlackBerry Email app, I need to setup a test environment so I can test mail send in the BlackBerry simulator.
I did some research, I read the RIM related document it does not help, then I find a solution from a good book about blackberry - Advanced BlackBerry Development, by Chris King.
I just follow the method from the book , and finally get it working, the solution is quite straight forward.
You need BlackBerry ESS ( Email Server Simulator) in order to simulate mail from your simulator, it comes with the JDE SDK and JDE component, currently I used JDK 4.5 , I prefer it because it's simulator is much faster to launch.
There are two mode you can choose - Connected mode or Standalone mode.
I tired the connected mode, it does not working.
The book recommend using the Standalone mode: ESS will listen the localhost port, send out email to your smtp email client. If you set up your email client, choose localhost as server address, and configure the same pop3 and smtp port as ESS configured, your email client will receive the email.
Choose "Standandalone mode", set Pop3 port and Smtp port, I choose default value, which are 995 and 465.
Click Launch, the ESS will start, and you will say a dos command window displaying the server log information.
Then we need to configure your email client, I choose OutLook Express.
Add a new account, you can set up any email address,
Set localhost for both SMTP and POP3 server.
for POP3 port number ,use the same value of ESS: 465
for SMTP port number, use the same value of ESS:995
So far the configuration is finished, all you can do is launching the simulator.
You can start the blackberry email client, type any address, then send. Check your OutLook Express, you will find an incoming email.
And you can write an email from your outlook express, type any address, then send it. You will find the email in your blackberry simulator.
The only drawback is you can only send and receive email from your local machine. which is not real, but it is good enough to test the mail function in the simulator.
It is really good, I tested over 100 email using the solution above.
Finally I want to talk about a little about the book, it covers many good topics, such as BES, BIS which confuses me for a long time. Even I haven't finished it, but I think it is one of the best blackberry book so far.
I did some research, I read the RIM related document it does not help, then I find a solution from a good book about blackberry - Advanced BlackBerry Development, by Chris King.
I just follow the method from the book , and finally get it working, the solution is quite straight forward.
You need BlackBerry ESS ( Email Server Simulator) in order to simulate mail from your simulator, it comes with the JDE SDK and JDE component, currently I used JDK 4.5 , I prefer it because it's simulator is much faster to launch.
There are two mode you can choose - Connected mode or Standalone mode.
I tired the connected mode, it does not working.
The book recommend using the Standalone mode: ESS will listen the localhost port, send out email to your smtp email client. If you set up your email client, choose localhost as server address, and configure the same pop3 and smtp port as ESS configured, your email client will receive the email.
Choose "Standandalone mode", set Pop3 port and Smtp port, I choose default value, which are 995 and 465.
Click Launch, the ESS will start, and you will say a dos command window displaying the server log information.
Then we need to configure your email client, I choose OutLook Express.
Add a new account, you can set up any email address,
Set localhost for both SMTP and POP3 server.
for POP3 port number ,use the same value of ESS: 465
for SMTP port number, use the same value of ESS:995
So far the configuration is finished, all you can do is launching the simulator.
You can start the blackberry email client, type any address, then send. Check your OutLook Express, you will find an incoming email.
And you can write an email from your outlook express, type any address, then send it. You will find the email in your blackberry simulator.
The only drawback is you can only send and receive email from your local machine. which is not real, but it is good enough to test the mail function in the simulator.
It is really good, I tested over 100 email using the solution above.
Finally I want to talk about a little about the book, it covers many good topics, such as BES, BIS which confuses me for a long time. Even I haven't finished it, but I think it is one of the best blackberry book so far.
Subscribe to:
Posts (Atom)