pagetop
Javablog
by Java coders, for Java codersRSS

J2ME Development on OS X, revisited

January 17th, 2008 by

UPDATE: SINCE THIS POST WAS WRITTEN SUN HAVE RELEASED Java Platform Micro Edition Software Development Kit 3.0 for Mac OS. PLEASE USE IT INSTEAD OF THESE INSTRUCTIONS IF YOU HAVE AN INTEL APPLE.

Some time ago, I posted a tutorial for setting up a J2ME development environment on OS X. Since then, EclipseME has not been addressing any of the bugs that made it a pain to use and I have also moved on to NetBeans 6.0. In this post I will revisit how to set up a cross-platform J2ME development environment using Ant and Antenna to handle all the difficult pieces of the build process, but allowing your preferred IDE to perform pure-Java debugging through the use of the excellent MicroEmu “WTK”.

Glossary

I’ll assume that you are familiar with standard Java desktop (J2SE) development. But you might not be familiar with a few terms used specifically in the Java mobile domain (J2ME)

  • J2ME is ambiguous… the kind of J2ME we are talking about is CLDC/MIDP which means mobile phones. CDC are the higher end devices such as DVD players. Only I have never actually seen any CDC devices.
  • CLDC/MIDP/CDC are verbose names for the system class libraries on the device… instead of J2SE’s classes you get a ridiculously small subset plus some custom classes for persistence and user input.
  • JSR is an official extension library to Java. Many of the recent JSRs have been J2ME-specific and include support for things such as location awareness, bluetooth, camera-phones and text messaging.
  • MIDlet is the technical name of a J2ME application. There can be more than one MIDlet in a jar file.
  • JAD is the Java Application Descriptor file that is associated to a jar file, it’s like a manifest file but contains additional information such as digital signatures, security permission requests, where to get the jar file and how big it is. It is not necessary on all phones, but you won’t be able to sign your jars without one.
  • WTK is a Wireless ToolKit. Development side, a WTK provides a device emulator for running your MIDlets with step debugging, system libraries and provides several additional tools.
  • Preverification. For various technical reasons, J2ME devices cannot run a jar file that has been compiled by a Java compiler… but they almost can. The final step is to preverify the jar file and do some computations on class validity that are expensive at runtime, so that your phone doesn’t have to do it. Unfortunately SUN did not have the foresight to release a Java preverifier, and is therefore the primary restriction for cross-platform J2ME development. (for example, there is no PPC Linux preverifier)
  • Obfuscation. Which involves renaming all your class and variable names in the final jar… this results in a much smaller file.

Dependencies

I’ll assume you have a JDK, Ant and an IDE. You’ll need to download quite a few additional packages

  • Antenna to add a lot more functionality to Ant. This is optional if you intend to use NetBeans, in which case you can get by with installing the Mobility plugin. If you use Eclipse, you should get this… EclipseME is only maintained by one guy, part time, and it shows.
  • MicroEmu, get the 2.0.2 snapshot at least. This will provide you with a pure Java emulator allowing you to do step debugging in NetBeans and Eclipse. If you are on Windows/Linux, feel free to grab a few other development kits!
  • SUN WTK This is SUN’s non-portable Wireless ToolKit (WTK). We are only going to extract the device system libraries. I honestly cannot believe SUN for releasing a C-based emulator. OK, so a JVM running a mini-JVM does sound a bit incestuous, but performance isn’t the priority.
  • PhoneME (get the MR2 source at least). This is the open source complement of SUN’s non-portable Wireless ToolKit (WTK). We only want the preverifier binary.
  • Bluecove for bluetooth support on OS X and Windows. Linux users go to Avetanna.
  • ProGuard for code obfuscation and more importantly, making the jar as small as possible.
  • BluetoothDeploy optionally, my little bluetooth deployer application which will automate the delivery of your MIDlet to your mobile device.

The initial setup of all this middleware is a little tricky. You must create a folder named “bin” and another called “lib”. In the “bin” folder, you must place the preverify binary that is appropriate to your system from the PhoneME project. On OS X, this can be found in the phoneme_feature/cldc/build/share/bin/darwin_powerpc/ folder of the MR2 source download. In the lib folder you must place all the jar files from the WTK2.5.2/lib folder of the SUN WTK. I also place all the Javadocs from SUN’s WTK in there too, but you’ll find that they aren’t all available and those that are are useless you will have to go looking for them elsewhere. I found that the Sony WTK and Nokia developer pages tend to have more complete Javadocs. Checking out the JCP is mostly useless as everything tends to be in PDF.

Setting up in your IDE

In your IDE (except NetBeans), set up a Java project as normal with compiler compliance set to 1.3 (no generics in J2ME I’m afraid!). Instead of adding a system library… add the midpapi20.jar and cldcapi11.jar from the lib folder we just created. This means you will now have access to the MIDP-2.0 and CLDC 1.1 APIs which are the most common system libraries on modern handsets. You might want to spend a while getting acquainted with what is (and isn’t!) a part of those APIs by following the links. You can then add additional JSRs such as the JSR-82, the Bluetooth API… note that JSRs are device-dependent. You might want to check out a database like Polish to see if your target devices have the JSRs you want to use.

When you actually want to run your MIDlet in pure Java-land, you must use a different classpath. On the runtime classpath, add the MicroEmu and Bluecove jars. Run the org.microemu.app.Main class with your MIDlet’s full classname as a parameter. This will give you step debugging in Eclipse.

If you are using NetBeans 6.0, then install the Mobility plugin and setup a custom J2ME System Library by selecting the directory where you created the “bin” and “lib” folders. The emulator binary does not exist in our setup, so change it to run the MicroEmu application, with the appropriate classpath. The support offered by this plugin means you might not even need to edit any Ant scripts.

Hello World

There are loads and loads of tutorials out there on starting the actual work of writing a MIDlet. For now, I’ll give you the basic “Hello World”, and suggest that you just dig into the CLDC/MIDP Javadocs and Google for appropriate tutorials.

There is no main method in J2ME. You define your entrance classes in the JAD file, which must extend the javax.microedition.midlet.MIDlet abstract class. The methods startApp, pauseApp and destroyApp define a MIDlet’s life cycle and you must try your best to ensure that pauseApp releases as many resources as possible back to the system and that startApp can handle both a cold start and recover from a pause. I won’t address these issues in this little example, but be ware of them.

There is no Swing or AWT in J2ME, instead you add javax.microedition.lcdui.Items (such as text, images, etc) onto a javax.microedition.lcdui.Displayable. Or draw on the javax.microedition.lcdui.Canvas directly. Game developers will want to go straight to the javax.microedition.lcdui.game.GameCanvas

User input is handled through setting up an implementation of javax.microedition.lcdui.CommandListener to listen to javax.microedition.lcdui.Commands.

So, “Hello World” looks something like

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class HelloWorld extends MIDlet implements CommandListener {
    private final Command exitCommand;
    private final Form form;
 
    public HelloWorld() {
        exitCommand = new Command("Exit", Command.EXIT, 1);
        form = new Form("Hello World!");
        form.append("from JavaBlog.co.uk");
        form.addCommand(exitCommand);
        form.setCommandListener(this);
    }
 
    protected void startApp() {
        Display.getDisplay(this).setCurrent(form);
    }
 
    protected void pauseApp() {}
    protected void destroyApp(boolean force) {}
 
    public void commandAction(Command cmd, Displayable disp) {
        if (cmd == exitCommand) {
            destroyApp(false);
            notifyDestroyed();
        }
    }
}

As a first exercise… try adding a javax.microedition.lcdui.TextBox and handling the life cycle of a pause-unpause.

Antenna

Setting up an Ant build script may sound a little scary if you’ve never used it before. However, it’s not that bad. First define some properties that will be useful (you’ll need to edit the paths to suit your setup, note that “wtk” is where we created the “bin” and “lib” folders earlier)

<taskdef resource="antenna.properties" classpath="../middleware/antenna/antenna-bin-1.0.0.jar" />
<property name="wtk.proguard.home" value="../middleware/proguard/proguard4.1/" />
<property name="wtk.home" value="../middleware/wtk/" />
<property name="jsr82.jar" value="../middleware/bluecove/bluecove-2.0.2.jar" />
<property name="btdeploy.jar" value="../middleware/bluetoothdeploy/bluetoothdeploy.jar" />
<property name="microemu.jar" value="../middleware/microemu/microemulator-2.0.2-SNAPSHOT.jar" />
<property name="wtk.midp.version" value="2.0" />
<property name="wtk.cldc.version" value="1.1" />
<property name="wtk.bluetooth.enabled" value="true" />

There are lots of other properties that Antenna recognises for setting up the device profile. I suggest you have a browse of them on the Antenna properties list. You now have access to lots of new Ant tasks for building, preverification, creating the JAD file (it’s like an external manifest file, but more of a pain) and digital signing (if you have paid for a certificate).

Typically, you’ll want to create a target that looks something like this

<target name="build">
    <wtkjad version="0.0.1" name="MyApp" vendor="Me!" jadfile="myapp.jad" jarfile="myapp.jar">
        <!-- typically 3 MIDlets are supported by devices -->
        <midlet name="Test Suite" class="my.package.MyAppTests" />
        <midlet name="My Application" class="my.package.MyApp" />
    </wtkjad>
    <mkdir dir="build/classes" />
    <wtkbuild srcdir="src" destdir="build/classes" preverify="false" />
    <wtkpackage obfuscate="false" preverify="false" jadfile="myapp.jad" jarfile="myapp.jar">
        <fileset dir="build/classes" />
        <fileset dir="res" />
    </wtkpackage>
    <wtkobfuscate jadfile="myapp.jad" jarfile="myapp.jar" />
    <wtkpreverify jadfile="myapp.jad" jarfile="myapp.jar" />
</target>

and that’s it! Running ant build will now build your MIDlet and create a jar and jad file that you can send to you phone. Well, almost… there is a bug with the wtkpreverify line, and I have to type this instead

<mkdir dir="build/tmp" />
<exec executable="${wtk.home}/bin/preverify">
    <arg line="-classpath ${wtk.home}/lib/cldcapi11.jar:${wtk.home}/lib/midpapi20.jar:${wtk.home}/lib/jsr082.jar" />
    <arg line="-d build/tmp" />
    <arg line="${tests-jarfile}" />
</exec>
<move file="build/tmp/${tests-jarfile}" tofile="myapp.jar" />
<delete dir="build/tmp" />
<wtkjad update="true" jadfile="myapp.jad" jarfile="myapp.jar" />

which is a bit ugly. If you use digital signing, then you can use a line like this to do all that

<wtksign keystore=".keystore" jadfile="myapp.jad" jarfile="myapp.jar"
  storepass="${keystore.pass}" certpass="${cert.pass}" certalias="${cert.alias}" />

I’ll leave you to work out the details… setting up a certificate can be a real pain in the butt. Read David Hayes’ excellent tutorial on getting the keys set up.

If you want to be really fancy, you can create a deploy target which will send the MIDlet to your handset with

<target name="deploy" depends="build">
    <java fork="yes" classname="thinktank.j2me.j2se.BluetoothDeploy" classpath="${btdeploy.jar}:${jsr82.jar}">
        <arg line="INSERT YOUR HARDWARE ADDRESS HERE" />
        <arg line="myapp.jad" />
        <arg line="myapp.jad" />
    </java>
</target>

see my previous post for more details.

Future developments

The future looks bright for better cross-platform support, as the ProGuard developers are working on a pure-Java preverifier, although it is pretty buggy at the moment. MicroEmu will then be able to bundle such a preverifier and change their naming conventions of JSR stubs to conform with the SUN WTK, making your IDE think it is the SUN WTK. It would also be good if MicroEmu came with a bin/emulator script that spoke with the Java debugger… it would make IDE setup even easier.

But really, the Mobile Java future has got to be either Android or JavaFX! Both are better than CLDC/MIDP J2ME, so it’s really up to the handset manufacturers to decide. Personally, I prefer Android because it will allow me to edit the firmware and have a truly open source Mobile OS.


This entry was posted by by on Thursday, January 17th, 2008 at 2:55 pm, and is filed under Android, Ant, cross-platform, Eclipse, EclipseME, J2ME, Java, JSR-82, MIDlets, Mobile, NetBeans, OS X, Signing. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.



31 comments on “J2ME Development on OS X, revisited”

Heya,

Thanks for a great page! You’ve saved me many hours of hunting around.

For newbies, I think it would be helpful to mention just how to install Sun’s WTK and extract the preverify binary from phoneME.

  • Download the Linux build of WTK (sun_java_wireless_toolkit-2_5_2-linux.bin)
  • Execute the downloaded file (sh sun_java_wireless_toolkit-2_5_2-linux.bin)
  • When asked for a path to JDK, enter “/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/”
  • Follow the instructions, probably best to install into /Applications/WTK2.5.2
  • Extract phoneME build (it creates a directory called “phoneme_feature”
  • Copy /phoneme_feature/cldc/build/share/bin/darwin_powerpc/preverify over the preverify binary that came with WTK.

Done!

Cheers, Dan

Thanks Dan… although I found that typing /usr/bin was enough to keep the installer happy instead of the longer one you mention. I also just extracted the WTK to the current directory, grabbed all the jar (and javadoc) files and deleted it. But feel free to keep it installed… just don’t expect it to do anything ;-)

just wanted to mention that bluecove supports linux (bluez) too since version 2.0.3. i’ve found that avetana is a bit buggy, even the commercial version. hopefully bluecove gives me less headaches.

@onitake I was aware that Vlad was writing Linux support… but I did not expect him to do it so quickly! 2.0.3 is still in beta, but I don’t expect it will be long until a final release if you are saying it is working for you. Great stuff.

Hi, A very useful page - finally a good way to do j2me development on os x! Got everything compiling with Netbeans 6.0 but now am stuck getting it to execute and debug using microemu. What did you enter into the Java platform manager dialog’s Execution and Debugging commands to get it to work? Thanks! Tim

@Tim it should be mostly as it is… but change the emulator binary to something like java -cp /path/to/microemu.jar org.microemu.app.Main

Also, don’t forget to update your ~/.netbeans/6.0/config/Services/Platforms/org-netbeans-api-java-Platform/J2ME.xml file to point at the correct javadoc paths within your archives. This is a bug in NetBeans 6.0 and will be fixed in 6.1.

Hmm… that’s what I thought, but when I try it, or something similar, the output window shows:

Starting emulator in execution mode
java.io.IOException: java -jar /Users/timsa/Documents/Projects/j2me/bin/microemulator-2.0.2-SNAPSHOT/microemulator.jar: not found
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.(UNIXProcess.java:52)
        at java.lang.ProcessImpl.start(ProcessImpl.java:91)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
        at java.lang.Runtime.exec(Runtime.java:591)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.netbeans.mobility.antext.RunTask.doExecute(RunTask.java:391)
        at org.netbeans.mobility.antext.RunTask.execute(RunTask.java:344)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor252.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
BUILD FAILED (total time: 0 seconds)

Yet the same command line (cut and pasted) works fine from the Terminal. :(

@Tim you’re using -jar instead of -cp which could be the issue. Also… don’t delete the stuff after the emulator command, as you still need to pass parameters to the executable. I mean to replace the “{path{/}emulator}”, not the entire text. Try to turn on NetBeans debugging somehow to see if there is a way to get it to log the exact command it is using. Please post your results here! I must admit, I don’t use the Mobility plugin yet for MIDlets (just for library projects) as I still have all my projects building from ant scripts. I really should get around to upgrading my setup.

Hello,

Thanks for getting back to me again… and my apologies for being unclear. In the example I posted I was using the -jar method, but I’ve tried all the combinations of the -cp approach I could think of, as well. I also tried keeping the parameters sections as is, and later on various attempts at hardcoding it just to get the emulator to start at least. Nothing working. Being new to Netbeans I’m not sure what extra debug things it might print out, or how to activate it. A search of the likeliest menus hasn’t turned up anything.

The only partial success I’ve had is by making a shell script called ‘emulator’ in the /bin folder (where Netbeans expects it) and having it run the java command. In this case the command is found and the emulator starts (which makes me think that the problem above is to do with having multiple parts to the binary executable name? Maybe). But even though this method starts up the emulator it appears to fail to recognise the command line passed in and prints out errors for any -Xdescriptor parameters. That could be a problem with MicroEmu though.

I’m interested that you’re using the ant building approach with Netbeans. Does this let you do single-step debugging in the emulator? That would work for me - I don’t have to use the mobility approach, I just thought that was the right way to go. Being able to debug the app without resorting to println is the key thing!

cheers, Tim

[…] (in which case you will have to resort in a parallels/crossover/bootcamp Windows emulation). This nice tutorial covers all the needed workarounds in details: the steps are simple (although not so obvious) - in […]

[…] for Darwin platform. After some Googleing, I found from Javablog a tutorial on how to develop J2ME on OSX. Below is a screen shot showing an J2ME application running on my […]

Hi!

Thanks for this article. I will try it.

You said: “Only I have never actually seen any CDC devices.”. Well, the sony Ericsson P1 is CDC and CLDC device. See http://developer.sonyericsson.com/site/global/products/phonegallery/p1/p_p1.jsp

Mario

I tried to configure an IntelliJ build configuration (MacOSX 10.5, Java 5, IntelliJ 7) to run the HelloWorld midlet with MicroEmu 2.0.2, but I got the following error:

/System/Library/Frameworks/JavaVM.framework/Home/bin/java -Dfile.encoding=MacRoman -classpath /System/Library/Frameworks/JavaVM.framework/Home/lib/deploy.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/dt.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/javaws.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/jce.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/plugin.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/sa-jdi.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/charsets.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/dt.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/jconsole.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/jsse.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/Home/../Classes/ui.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext/apple_provider.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext/dnsns.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext/localedata.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext/sunjce_provider.jar:/System/Library/Frameworks/JavaVM.framework/Home/lib/ext/sunpkcs11.jar:/Users/sarbogast/dev/mobimap/target/classes:/Applications/mwtk/lib/cldcapi11.jar:/Applications/mwtk/lib/midpapi20.jar:/Applications/microemulator-2.0.2/microemulator.jar org.microemu.app.Main org.epseelon.mobimap.HelloWorld
2008-06-06 19:50:59.752 java[3507:80f] LCC Scroll Enhancer loaded
Exception in thread "main" java.lang.UnsatisfiedLinkError: getProperty0
    at com.sun.midp.main.Configuration.getProperty0(Native Method)
    at com.sun.midp.main.Configuration.getProperty(Configuration.java:33)
    at com.sun.midp.midlet.Scheduler.getScheduler(Scheduler.java:144)
    at com.sun.midp.midlet.MIDletState.(MIDletState.java:301)
    at javax.microedition.midlet.MIDletProxy.(MIDletProxy.java:33)
    at javax.microedition.midlet.MIDlet.(MIDlet.java:70)
    at org.microemu.app.launcher.Launcher.(Launcher.java:50)
    at org.microemu.app.Common.(Common.java:125)
    at org.microemu.app.Main.(Main.java:750)
    at org.microemu.app.Main.(Main.java:628)
    at org.microemu.app.Main.main(Main.java:874)

Any idea what the problem might be?

@Sebastian it looks like you’re using the MIDP/CLDC native libs when starting MicroEmu, you should be using your J2SE environment when starting it… the MIDP/CLDC libs are for the preverification step and authoring. Try asking on the MicroEmu mailing list for further advice.

I have followed your instructions but end up getting the following error when trying to build:

do-preverify:
Preverifying 38 file(s) into /Users/cchiappone/GPS/GpsTest/build/preverified directory.
java.io.IOException: /Users/cchiappone/J2ME/bin/preverify: cannot execute
        at java.lang.UNIXProcess.forkAndExec(Native Method)
        at java.lang.UNIXProcess.(UNIXProcess.java:52)
        at java.lang.ProcessImpl.start(ProcessImpl.java:91)
        at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
        at java.lang.Runtime.exec(Runtime.java:591)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Execute.java:828)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:445)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:459)
        at org.netbeans.mobility.antext.PreverifyTask.execute(PreverifyTask.java:225)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
BUILD FAILED (total time: 0 seconds)

[…] but I haven’t tried it.) I’m gonna keep this short so I can work on it. There’s this cat that’s blogging about doing cross platform JavaME development and I’m reading the blog […]

[…] on Mac OS X. JustDev and FaqMobilityMpowerMacOs describe one approach using the MPowerPlayer SDK. Javablog has an article using the MicroEMU […]

Chris (another one) wrote:

In reply to Chris above:

I ran into that. Luckily it’s a simple fix (if you’ve not found it already!). You’ve got to set the executable attribute on the bin/preverify binary.

A simple

chmod u+x preverify
should make that runnable and get rid of that error.

Unfortunately, I’ve then hit a problem. Compiling a simple ‘Hello’ app, I get:

do-preverify:
Preverifying 1 file(s) into /Users/chris/NetBeansProjects/Test/build/preverified directory.
Error preverifying class java.lang.String
    VERIFIER ERROR java/lang/Object.getClass()Ljava/lang/Class;:
Empty code
/Users/chris/NetBeansProjects/Test/nbproject/build-impl.xml:249: Preverification failed with error code 1.
BUILD FAILED (total time: 0 seconds)

… and I’m stuck :)

Any help greatly appreciated!

Chris (another one) wrote:

blush

That error would be because… there’s… well, no code :)

I didn’t have open what I thought I had open. Nevermind!

Chris (another one) wrote:

Bah! Even with some code in there I’m getting that error.

Apologies for the comment-spam!

Hi, I’m pretty stuck with paths in ant. I’m using Eclipse, and if I put the “middleware” folder structure inside the project folder (same level as build.xml) then everything works fine. As soon as I move it somewhere else, even the parent folder, and try to do:

<taskdef resource="antenna.properties" classpath="../middleware/antenna/antenna-bin-1.0.0.jar" />

it won’t find the antenna jar (same goes for all the property files). It won’t even accept/find absolute paths. Where am I doing something wrong?

Any help would be much appreciated :)

Thanks!

gustavo de paula wrote:

i just saw this blog about javame on macosx. just to let everyone know, eclipseME was contributed to eclipse foundation and is the base of Eclipse DSDP Mobile Tools for Java project (MTJ). Most of the issues related to macosx supported were fix on MTJ and it is possible to use MTJ on macosx both with microemu and mpower player. the only difference is that microemu required that you download and setup an external preverifier while mpower player already comes with one.

mtj page is: http://www.eclipse.org/dsdp/mtj :) gep

Any hints on a reverifier that works with MicroEmulator on OS/X. I downloaded and extracted one from a kit as per instructions elsewhere. It includes stubs for all the stuff a phone will have native. It works fine with Antenna, but no good in Eclipse. I tried the one for PowerPlayer. Works OK with powerplayer but not with MicroEmulator. As above I get

Error preverifying class java.lang.String VERIFIER ERROR java/lang/Object.getClass()Ljava/lang/Class;:

The only libraries are the ones supplied with MicroEmulator.

Powerplayer works, but does not work with my software - that works on 3 phones and multiple other emulations. Besides, I prefer MicroEmulator.

I use Netbeans 6.5 on OS/X intel. when I use WTK2.5.2 as mobile platform and change preverify with the one from PhoneME. It builds jar and jad, but errors when trying to emulate with Sun WTK phone emulator. Eventhough it can be emulated with microemulator


Starting emulator in execution mode
java.lang.UnsatisfiedLinkError: /Applications/WTK2.5.2/bin/sublime.so: 
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)

but when I use custom platform as mentioned in this blog (directory with ./bin/preverify from PhoneME and ./lib/*.jar from WTK2.5.2) I got error when preverifying.

Error preverifying class java.lang.String
    VERIFIER ERROR java/lang/Object.getClass()Ljava/lang/Class;:
Empty code
../Workspace/MobileApplication1/nbproject/build-impl.xml:475: Preverification failed with error code 1.
BUILD FAILED (total time: 0 seconds)

any clue to solve this?

thank you.

@bho, first try reading this blog post instead of instantly assuming it’s a help forum (which it isn’t, btw).

Your readers might be interested to know that Motorola has just released a preview of MOTODEV Studio for Java ME. This is a complete, Eclipse based IDE for developing MIDLets on Mac OS X 10.5 systems. The package consists of Eclipse, MTJ, and an SDK for developing MIDLets for Motorola and other phones. The entire kit is available from http://developer.motorola.com/ at no charge.

Eric SPD, Motorola

Given problems such as this, there is a strong possibility of the Java ME platform drifting into obscurity. Rightly or wrongly the pace of mobile development is being driven by Apple and there are legions of developers with a fantastic range of skills and knowledge of mobile development writing fantastic applications ON MACS! Many of these, myself included, are now branching out and applying our skills to other platforms and have high expectations of a seamless and high quality experience.

It is clear that Google recognise this and are actively courting these developers. In addition to their SDK they have released an Eclipse plugin that makes it EASY to start Android programming ON MACS! I have also now started learning how to develop applications for WebOS on the Pre since they have also simplified the development process.

My day job is running a degree in Mobile Development in a University faculty that uses Apple Macs and as a result students are being taught three platforms: iPhone, Android and from September WebOS. We are producing dozens of skilled Mobile Developers ready to contribute to a growing marketplace and NONE OF THEM will be using JavaME. Is that not rather worrying? It would worry me.

The lame excuses given in the previous post will have to give way to a motivation to make it as easy to develop JavaME applications on ANY PLATFORM as it is to develop Android apps. Unless this happens the platform will continue its drift into obscurity. And the worrying thing is it does not have much further to go…

M

Motorola updated their SDK to work with OSX:

http://developer.motorola.com/docstools/motodevstudio/javame/downloads/

works fine with the Eclipse ME and MJT plugins for Eclipse.

can any one tell using J2SE can I develop android apps or only J2ME is used for this purpose.

[…] advice on how to do this on the web. The two articles that I found the most helpful were probably J2ME development on OS X revisited and Do-it-yourself midp on OS X (which is fairly old). The source code bundle downloadable from […]

Leave a comment

Markdown is supported.

To include code snippets in your comment, use

<pre><code># lang java
... code here ...
</code></pre>

or use 4 spaces at the start of the line instead of using code and pre tags.

Comment feed: RSS