BlackBerry Simulator in Linux – Sort of

8800 Simulator in Wine/Linux
8800 Simulator in Wine/Linux

Call me crazy but I just can’t seem to accept that if you want to (or have to) write BlackBerry software you’re stuck with Windows. It bugs me.

There is good news and bad news regarding the simulator. The good news is with a recent version of Wine you can actually get the BlackBerry simulator to run. The bad news is that it’s a bit buggy, and debugging hardly works at all.



What to expect

Your millage may vary! Generally I find that the simulator is usable for most testing. Attaching a debugger to it (via JDWP) just seems to cause the simulator to hang. Mind you, I have a rather slow system (AMD XP 2500+) and I would love to hear about your experiences if you have a faster computer.

Ingredients

Wine – You need the most recent version you can get your hands on. The package in the Ubuntu repository won’t due. So if you have installed this one, remove it and follow these instructions to get the latest and greatest.

For some reason until I performed the following steps, the simulator would always crash on startup:

  1. rm -rf ~/.wine
  2. Start up winecfg
  3. Applications tab – select Windows 2000 from the dropdown list
  4. Audio tab – select ALSA Driver from the drivers list

It should go without saying that you will need a copy of the JDE or one of the simulator packages. If you have access to a Windows box, just zip up the JDE or simulator and copy over. Otherwise, there are a few tricks to extracting the contents of the setup package.

Extract the setup package:
wine BlackBerry_JDE_4.2.1.exe /extract:c:\\

Which extracts the files to ~/.wine/drive_c/

Use msiexec to install the package:
wine msiexec /a c:\\jde_installer.msi /qn

Which extracts the file to ~/.wine/drive_c/Program Files/Research In Motion/BlackBerry JDE 4.2.1. This is a cumbersome path at best so move this somewhere more usable:
mv ~/.wine/drive_c/Program Files/Research In Motion/BlackBerry JDE 4.2.1 ~/lib/JDE4.2.1

Cleanup:
rm ~/.wine/drive_c/jde_*

Run the simulator

I created a shell script from one of the existing batch files for launching:
cat 8800.bat | dos2unix > 8800.sh
gvim 8800.sh

Replace the @echo off with #!/bin/bash and insert the wine command before the fledge.exe. Mine looks like this:

#!/bin/bash
wine fledge.exe /app=Jvm.dll /handheld=8800 /session=8800 \\
/app-param=DisableRegistration /app-param=JvmAlxConfigFile:8800.xml \\
/data-port=0x4d44 /data-port=0x4d4e /pin=0x2100000A

Set the execute permission:
chmod +x 8800.sh

Now just run it!
./8800.sh

Don’t give up if the first time you run it the thing crashes. Give it a few tries.

Debugger

So you fancy yourself an adventurer do ya!?! Well, good luck.

Thankfully, RIM hasn’t made the same mistake with JDWP as they did with the signature tool but you will still have to modify a number of text files to convert the Windows path names to Unix ones.

cd ~/lib/JDE4.2.1/bin
cp SimPackage-JDE.rc SimPackage-JDE.orig
cat SimPackage-JDE.orig | sed 's/\(Command.*\)=%/\1=wine %/' | sed 's/\\/\//g' > SimPackage-JDE.rc

cp FixedBuild.rc FixedBuild.orig
cat FixedBuild.orig | sed 's/\(Command.*\)=%/\1=wine %/' | sed 's/\\/\//g' > FixedBuild.rc

cp DefaultBuild.rc DefaultBuild.orig
cat DefaultBuild.orig | sed 's/\\/\//g' > DefaultBuild.rc

If you copied the JDE from a Windows box you might need to update other files. You must also remove Settings.rc if it already exists.

Make sure you have the Sun Java Runtime installed by running java -version. Now all that’s left is to start up the JDWP:
java -jar JDWP.jar

On startup, there will be an error message about RIMUsbJni.dll but you can safely ignore this. And that’s just about it; your JDWP client connects as usual (jdb, eclipse, netbeans). Feel free to leave your successes/failures in the comments.

Comments 27

  1. Paul wrote:

    When I try to run the simulator in wine I get:
    err:bitmap:DIB_GetBitmapInfo (44): unknown/wrong size for header
    err:seh:setup_exception stack overflow 24 bytes in thread 0009 eip 7eddd84f esp 00240fe8 stack 0×241000-0×350000
    Wine failed with return code 1
    The image of the 8703e does appear but I get a “Division by zero” error and a Microsoft Visual C++ Runtime Library error of “This application has requested the Runtime to terminate in an unusual way.”

    I’m running wine-0.9.25 / debian / gnome and BlackBerry device simulator 4.1.0.359.

    Any ideas? Anyone?

    Posted 03 Apr 2008 at 10:35 am
  2. Paul wrote:

    BTW, to be able to run the simulator through wine (and the MDS, which is not part of these instructions, if I understand correctly) would be wonderful. I’ve been wanting this for years.

    Posted 03 Apr 2008 at 10:54 am
  3. jiGGaK wrote:

    Paul, you are going to need a MUCH more recent version of wine than the one you have. In fact, I wouldn’t even bother unless you have the latest version (0.9.58).

    Posted 03 Apr 2008 at 12:04 pm
  4. Paul wrote:

    Doing so now… Thanks!

    Posted 03 Apr 2008 at 12:10 pm
  5. Paul wrote:

    Oh sweet Blackberries! It works using wine 0.9.58! THANK YOU!!!

    OK, now how do I get MDS to run?

    Posted 03 Apr 2008 at 12:23 pm
  6. jiGGaK wrote:

    Paul,

    Like this ;)

    Posted 03 Apr 2008 at 12:43 pm
  7. Paul wrote:

    Uh, ok. Same as the simulator. I’ll try that now…

    Posted 03 Apr 2008 at 12:52 pm
  8. Paul wrote:

    Ok, I’m of the noob variety. How to I convert the following to run as a shell script in Linux? … (or do I?)

    @echo off
    call setBMDSEnv
    
    if ["%JAVA_HOME%"] == [""] goto noJavaHomeSet
    	start cmd /v:on /c "%JAVA_HOME%\bin\java" -classpath !BMDS_CLASSPATH!;!BMDS_CLASSPATH2! -Xmx512M -DKeystore.Password=password net.rim.application.ipproxyservice.IPProxyServiceApplication -log.console.dump
    	goto end
    :noJavaHomeSet
    	start cmd /v:on /c java -classpath !BMDS_CLASSPATH!;!BMDS_CLASSPATH2! -Xmx512M -DKeystore.Password=password net.rim.application.ipproxyservice.IPProxyServiceApplication -log.console.dump
    	goto end
    :end
    

    Wait… Spider senses tingling … Isn’t this all just java? Could it be as easy as running it using my Linux java (i.e. nothing to do with wine)? Either way, you can still save me hours of hacking.

    Posted 03 Apr 2008 at 12:58 pm
  9. jiGGaK wrote:

    Paul,

    Are you serious? Go over to the post about the MDS simulator… there is a script already written for you, just copy/paste!

    And use the comments section over there for issues related to MDS please. Thanks.

    Posted 03 Apr 2008 at 1:09 pm
  10. Mack wrote:

    Hi:

    I’ve follow up your howto but the simulator don’t work, I’ve try it few times, but I got a few errors message like:

    Access violation reading from 0×00000024

    or the simulator init but it frozen when the Media Card Inserted message appear.

    I’ve wine 0.9.58 en JDE 4.2.1

    I’ll appreciate your help.

    Regards

    Posted 17 Apr 2008 at 8:29 pm
  11. Fred wrote:

    I can get the simulator to run, but the phone image is upside-down and backwards, while the LCD image is correct.

    Any idea what’s wrong or how to fix this?

    wine-1.0-1.fc8 & LDE 4.5.0

    Fred

    Posted 06 Jul 2008 at 9:38 pm
  12. jiGGaK wrote:

    Fred,

    I have the same problem with the 4.5.0 simulator and I haven’t found a way to make it work. It seems using an earlier version is the only option.

    Posted 07 Jul 2008 at 8:54 am
  13. Fred wrote:

    I managed to extract the phone “plastic” image and invert it (vertically) and then copy it back to the fledge.dat (zip) file. The plastics image files are in the /res/plastics/ folder in this zip file. That solved that problem.

    The LCD display is messed up when the simulated trackball is moved. That may be a problem with the flash player I’m using, but I can’t tell.

    Posted 07 Jul 2008 at 2:18 pm
  14. Cliff wrote:

    I’ve been at it time and again and I can’t seem to run rapc.exe from Linux or OSX! I’m not using rapc.jar directly because according to RIM the exe passes some secret but necessary values to the Jar. I went the path of invoking the jar directly but ultimately ended up with sporadic application crashes and preverify errors. From what I’ve learned all of the tools (except for the SignatureTool.jar) need to be at a version level equal to or lower than your target or you’ll be subject to random application failures and undefined behavior after compiling. Rolling my tool set back to version 4.2.1 almost forces me to use Windows because it (older rapc) relies on preverify (NOT preverify.exe) and javac being located in the PATH which means I have to wrapper preverify.exe with a shell that calls it under wine. (This much does work but is extremely painful.) There’s more to the story that I plan to post to my site soon.

    Posted 22 Aug 2008 at 4:30 pm
  15. Cay Horstmann wrote:

    I get the following error with Wine 1.0 in Ubuntu:

    fixme:file:MoveFileWithProgressW MOVEFILE_WRITE_THROUGH unimplemented
    fixme:gdiplus:GdipSaveGraphics graphics state not implemented
    fixme:gdiplus:GdipRestoreGraphics graphics state not implemented
    fixme:gdiplus:GdipCreateBitmapFromHBITMAP don’t know how to handle 16 bpp
    fixme:gdiplus:GdipSetClipRectI not implemented
    wine: Call from 0×7b844b20 to unimplemented function gdiplus.dll.GdipResetClip, aborting
    fixme:gdiplus:GdipCreateBitmapFromHBITMAP don’t know how to handle 16 bpp
    wine: Call from 0×7b844b20 to unimplemented function gdiplus.dll.GdipResetClip, aborting
    err:seh:setup_exception_record stack overflow 296 bytes in thread 001a eip 7b8539db esp 00241208 stack 0×240000-0×241000-0×340000

    The emulator shows with the upside-down display, but then it hangs.

    I then cleverly copied gdiplus.dll into the /windows/system32 directory of Wine, and those errors go away. Instead I get

    fixme:file:MoveFileWithProgressW MOVEFILE_WRITE_THROUGH unimplemented
    fixme:win:EnumDisplayDevicesW ((null),0,0×33eae8,0×00000000), stub!
    fixme:win:EnumDisplayDevicesW ((null),0,0×33eae8,0×00000000), stub!
    fixme:wtsapi:WTSRegisterSessionNotification Stub 0×1007e 0×00000000
    wine: Call from 0×3d10f08c to unimplemented function msvcrt.dll._ftol2_sse, aborting
    fixme:wtsapi:WTSUnRegisterSessionNotification Stub 0×1007e

    At this point, the app doesn’t come up at all. Sigh.

    Posted 10 Sep 2008 at 8:40 pm
  16. jiGGaK wrote:

    Recent versions of the simulator (4.5 and 4.6) don’t work very well under wine.

    Also, make sure your using the most recent version of Wine as possible.

    Posted 14 Sep 2008 at 8:51 pm
  17. Cay Horstmann wrote:

    Ok, now I installed the latest Wine (1.1.4).

    When running the 8800.sh file with JDE4.2.1, I get an

    Internal Error – BlackBerry Device Simulator
    ——————————————–
    Access violation reading from 0×0000000C

    Do I need Java installed under Wine?

    Posted 15 Sep 2008 at 5:56 pm
  18. jiGGaK wrote:

    Nope, you don’t need Java inside of wine.

    Sadly it’s hit or miss with getting this working. Even if it works it’s not that stable.

    However, you might try removing your ~/.wine directory and re-initializing it by running winecfg. I’m using WindowsXP emulation and I have alsa selected as the audio library.

    Note: removing ~/.wine will remove your virtual C: drive and all your wine settings.

    Posted 15 Sep 2008 at 6:19 pm
  19. Cay Horstmann wrote:

    Thanks. I tried all that, and no luck. FWIW, I get the exact same error with JDE4.3. It says “Error inside JVM – Access violation reading from 0×0000000C”.

    Posted 15 Sep 2008 at 8:24 pm
  20. mercy wrote:

    i faced the similar problem as you say.
    i.e “Error inside JVM – Access violation reading from 0×0000000C”.

    just run the clean.bat file from this path
    Program Files\Research In Motion\BlackBerry JDE 4.6.0\simulator
    just try…

    Posted 26 Sep 2008 at 12:23 am
  21. Patrick Waugh wrote:

    Article was helpful, although you have to also install MSXML.msi with:

    $ wine start MSXML.msi

    after which, all works wonderfully. :)

    Patrick

    Posted 31 Oct 2008 at 9:58 pm
  22. Jason wrote:

    Has anyone had more luck getting the newer JDK 4.6 version of the simulator to run in wine? When I try using winetricks to install gdiplus and msxml3, I still can’t get it to work.
    I get the following errors:
    fixme:file:MoveFileWithProgressW MOVEFILE_WRITE_THROUGH unimplemented
    fixme:win:EnumDisplayDevicesW ((null),0,0×32eb0c,0×00000000), stub!
    fixme:wtsapi:WTSRegisterSessionNotification Stub 0×10040 0×00000000
    fixme:dciman:DCICreatePrimary 0×584 0×27813a8
    fixme:wtsapi:WTSUnRegisterSessionNotification Stub 0×10040

    Posted 23 Nov 2008 at 11:27 pm
  23. afallenhope wrote:

    Hey, awesome tutorial,
    I was just wondering, do you have any way of getting eclipse to work? This is somewhat outdated however, most of the steps worked. Oh, I’d like to add the “thank a lot”, for the tutorial. I’m using wine 1.1.2

    Posted 15 Jan 2009 at 4:05 pm
  24. Andrey wrote:

    To fix

    “Access violation reading from 0×00000024″

    run the command on a single CPU

    taskset -c 0 wine fledge.exe …

    Wine has issues with SMP.

    Hope this will help someone.

    Posted 05 Apr 2009 at 11:38 pm
  25. Mate wrote:

    Great article.
    Works fine under Mac OS X 10.5.8.

    Posted 30 Oct 2009 at 3:36 am
  26. Arkka wrote:

    Hi,

    i’ve download Blackberry simulator and install via wine.

    And i have already instal MSXML.msi.

    But, there no picture on the screen (blank). But i can access the mainmenu.

    please help

    Posted 06 Jul 2010 at 11:59 pm
  27. jiGGaK wrote:

    I haven’t attempted to use the simulator under wine in several months. Even when I had, it was not very stable.

    Try using this guys article. Specifically, try installing GDI+ using winetricks script.

    Posted 07 Jul 2010 at 5:57 am

Trackbacks & Pingbacks 2

  1. From Slashdev - A Notch in the Cross Platform Blackberry Development Belt on 11 Mar 2009 at 9:03 am

    [...] the time of writing the first two worked fine. The third, Simulator, is if’y at best. And the fourth was just not [...]

  2. From Linux ?? BlackBerry ?????????? » ?????????(Giraffy) :: ???????????????? on 25 Nov 2009 at 1:31 am

    [...] Linux ???????????Linux ?? WINE ???????????????????????????????????? Bold [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *