Many times while coding an application for BlackBerry® smartphones, I want to quickly start the BlackBerry® Smartphone Simulator and see what I have achieved so far. Micro-iterative coding is my style of choice. I don’t need to debug any code, I just want to see it running; If it doesn’t work, then I’ll begin debugging. For those of you who share the same coding approach, here is a tip on how to make your BlackBerry Smartphone Simulator launch lightning fast.
BlackBerry Smartphone Simulator Initial Launch
The BlackBerry Smartphone Simulator keeps all simulated flash memory in .DMP files – you can find these in the simulator’s working directory. Whenever you need to get rid of any persistent data that you have accumulated, you can either delete these files manually or do it from within the BlackBerry® Java® Development Environment (BlackBerry JDE) or the BlackBerry® JDE Plug-in for Eclipse. This acts as a grand reset giving you the equivalent of a brand new BlackBerry® smartphone. However, the next time the BlackBerry Smartphone Simulator launches it will need to load all the OS files (including any applications it finds in the current directory) and link them within the newly created file system. This obviously takes time – possibly up to 3 minutes. On the IBM® ThinkPad W500 I use at work it takes 32 seconds which is still a considerable wait time.
So, rule number one: delete the BlackBerry Smartphone Simulator file system only when necessary.
There is also an option to automatically reset the file system every time you start the BlackBerry Smartphone Simulator – make sure it is also turned off unless you really need it.
- In the BlackBerry JDE, you can find it by selecting Edit -> Preferences -> Simulator -> Memory and unchecking the “reset file system on startup” option.
- In the BlackBerry JDE Plug-in for Eclipse, select Debug -> Run Configuration and uncheck the option under the Memory tab.
The debug session is a connection established between the BlackBerry JDE and the BlackBerry Smartphone Simulator to enable… well, debugging. Establishing a debugging session requires many prerequisites to be prepared both on the BlackBerry Smartphone Simulator side and on the debugging tool side. When the debugging session is established on my laptop it takes 32 seconds for initial launch and 16 seconds for subsequent runs. Without debugging it takes 23 seconds for initial launch and 10 seconds for subsequent launches!
Rule number two: establish a debug session only when you have a specific problem to debug.
Don’t worry – if you run the application and find a problem, you can still attach the debugger:
- In the BlackBerry JDE, select Debug -> Attach To -> Simulator or press Ctrl-Shift-0.
- In the BlackBerry JDE Plug-in for Eclipse, choose “Running BlackBerry Simulator” as your Debug Configuration.
How to run the BlackBerry Smartphone Simulator without Debugging
Now that it is apparent how much time we can save, let’s see what we need to do in order to avoid establishing a debug session. With the BlackBerry JDE Plug-in for Eclipse it’s pretty straightforward – simply select “Run” instead of “Debug” or use the CTRL-F11 shortcut and the BlackBerry Smartphone Simulator will launch right away. Using the BlackBerry JDE requires the slightly more involved process of creating a batch file:
- Open the BlackBerry Smartphone Simulator Properties menu and select Edit -> Preferences -> Simulator and then select the Advanced tab.
- Here you have the actual command line that can launch the BlackBerry Smartphone Simulator with all the necessary command line options; every time you change an option under the Simulator tab it is reflected in this command line. You also have the proper working directory where the BlackBerry Smartphone Simulator should start in order to pick up any compiled applications.
- Now you can create your runBBSim.bat:
- Now replace [workingDirectory] and [cmdLine] with the contents of the corresponding fields on the Advanced subtab of the BlackBerry Smartphone Simulator preferences: Command Line and Working Directory. Don’t forget to put quotes around any paths containing spaces to make the Windows command-prompt happy.
Here is what my batch file looks like:
pushd "C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0\bin\..\simulator"
"C:\Program Files\Research In Motion\BlackBerry JDE 4.7.0\bin\..\simulator\fledge.exe" /app=Jvm.dll /session=9500 /app-param=DisableRegistration /app-param=JvmAlxConfigFile:9500.xml /data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A /handheld=9500
Now you can compile the application in the BlackBerry JDE, start the batch file, and in 10 seconds you will have a running BlackBerry Smartphone Simulator with your application installed on it! Sounds like too much trouble? Believe me it’s worth the effort!
Do you have any other tricks for speeding up the BlackBerry Smartphone Simulator? Let us know by posting a comment.