Solved

J2me Gaming : Problem with Creating build(jar) for nokia phones

Posted on 2004-04-29
6
1,286 Views
Last Modified: 2012-05-04
Hi,

I am having trouble in making a package (jar) for  nokia phones. I have been tring using J2ME wireless kit, Eclipse, Nokia development Suite and IBM Device developer but havent been able to make a perfect package out of it.

I have even downloaded the plugins for Eclips but not able to configure it properly. I did every thing according to the specifications. but while building project i get the error "Problem while running the build script ....." .

Overall i want create a jar package and obufuscate that for Nokia phones.Its real urgent. Wud want someone to guide me on all the necessary.

Thanks in advance.
0
Comment
Question by:rayan2057
  • 2
6 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 10947750
What line is being indicated as the source of the problem in your build script?

What "script" are you referring to?

Are you using Ant to build the JAD/JAR?

I would recommend the Antenna ant extension: http://antenna.sourceforge.net/

When you say that you need to do a build for Nokia phones, do you mean you're using the Nokia APIs (eg. the Nokia UI or WMA?)
0
 

Author Comment

by:rayan2057
ID: 10949462
I am using Nokia Specific classes like FillCanvas and Sound so i am not able to make build

>> What "script" are you referring to?
  I am not referring to any script the plugin i have installed does not specify usage of any build script
  Plugin is: com.siptech.j2me
About "Antenna" is it a plugin for "Apache Ant" or it is a stand alone tool ?
0
 
LVL 15

Accepted Solution

by:
jimmack earned 75 total points
ID: 10949699
Antenna is an extension for Ant.  In order to use the Antenna facilities (eg. the targets for creating JADs, building, packaging, obfuscating etc.), you need to declare the targets in your Ant build file (build.xml).

Here is a same Ant build file that is a cut-down version of one I'm currently using.  This includes the Wireless Messaging API for Nokia 3410 (just to demonstrate how to include external libraries):

The wtkjad task is used to create the initial JAD file for the MIDlet.
The wtkpreprocess task handles the parts of the source that are conditionally included using the #ifdef support provided by Antenna, eg. in this case the following code:

//#ifdef WMA_ENABLED
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;
//#endif

is included.  If the symbols="WMA_ENABLED" text is missed, the preprocessor changes the above code to:

//#ifdef WMA_ENABLED
//import javax.wireless.messaging.MessageConnection;
//import javax.wireless.messaging.TextMessage;
//#endif

The preprocessed source code is now in the preproc directory and the wtkbuild task compiles this into the target directory using the bootclasspath to use the Nokia APIs rather than the standard ones.  I've also set the preverification within this task too.

The wtkpackage task then builds the JAD and JAR files, updating them with extra info (eg. config and profile), preverifies again (no particular reason for this) and obfuscates the JAR.  Note that the JAR file includes all the files in the target directory and the res (resource) directory except those specified by the excludes clause.

<?xml version = '1.0' encoding = 'ISO-8859-1' ?>
<project name="Sample" default="build" basedir="..">
  <property name="wtk.home" value="/usr/java/j2mewtk104"/>
  <property name="projroot" value="/home/jim/eclipse/workspace/MyProject" />
  <property name="src" value="${projroot}/src"/>
  <property name="res" value="${projroot}/res"/>
  <property name="preproc" value="${projroot}/preproc"/>
  <property name="target" value="${projroot}/target"/>
  <property name="target_dist" value="${projroot}/bin"/>
  <property name="version" value="1.0.0"/>
  <property name="nokiaWMA" value="/usr/java/nokia/3410/lib/classes.zip"/>
 
  <taskdef resource="antenna.properties"/>

  <target name="clean_build_dirs">
    <delete dir="${target}"/>
    <mkdir dir="${target}"/>
    <delete dir="${preproc}"/>
    <mkdir dir="${preproc}"/>
  </target>
 
  <target name="clean_target_dir">
    <delete dir="${target_dist}"/>
    <mkdir dir="${target_dist}"/>
  </target>
 
  <target name="build3410" depends="clean_build_dirs">
    <wtkjad jadfile="${target_dist}/MyProject.jad"
            jarfile="${target_dist}/MyProject.jar"
            name="MyProject"
            vendor="Objective Software Services Ltd."
            version="${version}">

        <midlet name="MyProject"
                icon="/images/icon.png"
                class="com.ossltd.MyProject"/>
    </wtkjad>

    <wtkpreprocess srcdir="${src}"
                   destdir="${preproc}"
                   symbols="WMA_ENABLED"/>
   
    <wtkbuild srcdir="${preproc}"
              destdir="${target}"
              preverify="true"
              bootclasspath="${nokiaWMA}"/>

    <wtkpackage jarfile="${target_dist}/TrainFinder.jar"
                jadfile="${target_dist}/TrainFinder.jad"
                bootclasspath="${nokiaWMA}"
                config="CLDC-1.0"
                profile="MIDP-1.0"
                obfuscate="true"
                preverify="true">
        <fileset dir="${target}">
          <exclude name="**/Monitor*"/>
        </fileset>
        <fileset dir="${res}">
          <exclude name="**/*9.dat"/>
        </fileset>
    </wtkpackage>
  </target>
</project>
0
 
LVL 3

Assisted Solution

by:JavaInTheMorning
JavaInTheMorning earned 75 total points
ID: 10957319
Since it's urgent, I think that the best way for now is to use the command line to do all that:
First compile the project:
d:\j2sdk1.4.0_02\bin\javac -g:none -target 1.1 *.java
// Then Jar it (change the dir to your Java dir).
d:\j2sdk1.4.0_02\bin\jar cfmv applicationName.jar manifest.mf *.class *.png sound\*.wav
// Then preverify it:
d:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\bin\preverify.exe -classpath d:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\lib\classes.zip;.\classes; -d .\verified applicationName.jar
copy verified
And then you can obfuscate it:
java -classpath c:\wtk104\bin\retroguard.jar;c:\wtk104\wtklib\emptyapi.zip;D:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\lib\classes.zip RetroGuard applicationName.jar applicationName2.jar ignore.rgs

D:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\bin\preverify.exe -classpath D:\Nokia\Devices\Nokia_7210_MIDP_SDK_v1_0\lib\classes.zip;.\classes applicationName2.jar

copy output\applicationName2.jar
del applicationName.jar
ren applicationName2.jar applicationName2.jar
// Then update the Jad file so it would state the correct size of the Jar file (manually).

Don't forget to change the paths to YOUR paths (nokia, jdk, etc.)
Hope it helps,
Itsik

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Multi-source agreements are important because they set standards that all manufacturers should follow to ensure that devices are compatible with multiple vendors. The multi-source agreement (MSA) is an agreement that establishes how multiple vendors…
Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now