Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
Excited About EJB 3.1 & JSF 2.0?
AJAXEnabled
Are you Ajax Enabled? Everybody else is...
Password Based Authentication Using Message Digests
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Using Antenna with Netbeans PDF Print
Written by Debashish Chakrabarty   
Mar 04, 2005 at 12:46 PM
Antenna [http://antenna.sourceforge.net]There has been a lot of buzz around Antenna, an Ant add-on for J2ME applications. Why! Can't I use Ant for this? You very well can, but Antenna elevates many Ant tasks that are peculiar to J2ME, for instance: updating the JAD for the correct JAR size, a task that doesn't matter as long as you are running your Midlets on the Wireless Toolkit (WTK) but is an absolute must for the Application Manager to be able to load your application on a real device.

** Be part of the Best Java Blogger Contest (Feb - Mar 2005)

This post doesn't talk about why J2ME developers should go for Antenna (see links at the end for pointers on that) but on how to use Antenna with Netbeans, an IDE for Java. Suffice to mention here that Antenna has brought in many Ant tasks that perform the key functions of the WTK including compilation, preverification, class file obfuscation, updating MIDlet-Jar-Size attribute in JAD and automatic generation of Manifest file. It goes without saying that since Antenna depends on the WTK you require the latter installed on your machine.

While Eclipse supports Antenna, as of now, Netbeans does not provide Antenna module, though it has built-in support for running Ant tasks. Infact using this support we can use Antenna with the IDE very easily. The solution has been tried on Netbeans 3.5/3.6. Here are the steps involved:

  • The first step obviously would be to download Antenna JAR file. Without the worry of using Antenna with Netbeans you may have dropped it in your Ant classpath (for eg: <Ant instllation path>lib), for here you may keep it anywhere because we will have to specify the path to Netbeans anyhow.
  • Start Netbeans. Go to Tools > Options > Building > Ant Settings > Properties. Add the following custom property (The property value will vary according to the actual Antenna JAR path on your machine):
    antenna.home=E:antenna-bin-0.9.12.jar
    Note the special way of specifying the file path on Windows .
  • Add the following to your build file:
    <taskdef classpath"${antenna.home}" resource="antenna.properties" />
    The antenna.properties file has been included in the Antenna jar and evades the worry of manually adding all the WTK tasks to your build file, such as:
    <taskdef name="wtkjad" classname="de.pleumann.antenna.WtkJad"/> <taskdef name="wtkbuild" classname="de.pleumann.antenna.WtkBuild"/> ...
    More details can be found at the Antenna homepage.
  • That's all. Now you may execute the build file.

 

You may find a sample Antenna build file here that I made to play with the application mentioned here. This assumes that you already have Proguard obfuscator downloaded and copied to bin folder of your WTK installation folder. Do note that for the wtkpackage task you should also Preverify (i.e. add attribute preverify=true) when your are Obfuscating (i.e. when obfuscate=true), this is needed because obfuscation destroys the extra information added by the preverifier. If you do not preverify you may get error similar to following when launching the application.

Running C:J2mewtkappsAntDemofinalAnimation.jad in DefaultColorPhone Error verifying method corej2me/a paint(Ljavax/microedition/lcdui/Graphics;)V Approximate bytecode offset 6: Inconsistent or missing stackmap at target ALERT: Error verifying class corej2me/a

 

Related links:

 

[Many thanks to J Pleumann, the creator of Antenna, for answering to my many queries and for the excellent free add-on.]


User Comments

Comment by mryzl on 2005-03-07 15:28:12
NetBeans 4.0 (+ NetBeans Mobility Pack) is ant based and already contains similar J2ME ant extension. It's very well integrated with the IDE, see for example how a source file with preprocessor directives is displayed in the editor and complete tutorial how to write an application for different devices: 
 
[URL=http://www.netbeans.org/images/screenshots/4.0/marv_miner.jpg]Screenshot[/URL] 
[URL=http://www.netbeans.org/kb/articles/tutorial-j2mefragmentation-40.html]Marv the Miner Tutorial[/URL] 
 
Latest NetBeans 4.1 Beta comes with MIDP Visual Editor which makes development of MIDP application even easier: 
 
[URL=http://www.netbeans.org/images/screenshots/4.1/nb_midp_visual_editor.png]Visual Editor Screenshot[/URL] 
[URL=http://www.netbeans.org/kb/41/quickstart-mobility.html]NetBeans 4.1 Quick Start[/URL] 
 
Unfortunately, there are some issues why Antenna cannot be bundled as a default ant library for NetBeans and why another ant extension is required.
Your Name / Email Address
Comment
Spam Protection - Please enter the code in the image -

Listen to code


Add This Feed Button

Enter your Email


Java Expert Interviews
JonasJacobiJSFAjax
Pure Ajax creates the next generation legacy applications
The future of the Java platform lies in the mobile world
ChristopherDuncan
Programmers lose because they are unwilling to learn any skill beyond the technical
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com