Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1390
  • Last Modified:

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

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
rayan2057
Asked:
rayan2057
  • 2
2 Solutions
 
jimmackCommented:
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
 
rayan2057Author Commented:
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
 
jimmackCommented:
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
 
JavaInTheMorningCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now