Compiling j2me using Ant

2019-07-20 16:05发布

I have created a J2ME project after referring to this article J2MEUsingAntwithJ2ME. Now I am having problems in adding resources (such as images) and libraries (such as jar and zip files). I have copied the resources in the res folder as shown in this article but when I extract the .jar file, it does not have any resources.

1条回答
爷的心禁止访问
2楼-- · 2019-07-20 16:54

From the sample:

<jar basedir="${build}/preverifiedobf"
     jarfile="${build}/bin/${program_name}.jar"
     manifest="bin/MANIFEST.MF">
  <fileset dir="${top}/${res}">
    <include name="${package_name}/*.png"/>
  </fileset>
</jar>

This will only include *.png files which are in /res folder. If you want to include more types, add more <include> lines or include "${package_name}/**".

If you want to include the content of existing .jar files, you can unjar them like this:

<mkdir dir="${build}/libs"/>
<unjar src="yourlibrary.jar" dest="${build}/libs" />

Then you can jar them up again:

<jar basedir="${build}/preverifiedobf"
     jarfile="${build}/bin/${program_name}.jar"
     manifest="bin/MANIFEST.MF">
  <fileset dir="${top}/${res}">
    <include name="${package_name}/*.png"/>
  </fileset>
  <fileset dir="${build}/libs">
    <include name="**/*"/>
  </fileset>
</jar>

The Apache Ant manual contains a lot of examples for all the supported tags.

查看更多
登录 后发表回答