J2ME Polish
J2ME Polish 2.4 Documentation
Enough Software

Integration

Integrating J2ME Polish into Eclipse

Please check out the Mepose Plugin for controlling J2ME Polish from within Eclipse. If you prefer using Ant, please follow the steps below:

To integrate J2ME Polish into Eclipse it is best to copy the sample application (the "sample" folder of your J2ME Polish installation) in your workspace. Then start Eclipse and create a new project called "sample". Eclipse then automatically integrates all source-files and sets the classpath. You should find the sample application now in the Package-Explorer (package de.enough.polish.example).

If the sources have not been integrated automatically, set the source-directory of the project to the "src" directory: Select "Project" -> "Properties..." -> "Java Build Path" -> "Source" and add the source-folder "src" there.

When the classpath was not set correctly, please include the following jar-files from the "${polish.home}/import" folder to your classpath:
import/midp2.jar, import/enough-j2mepolish-client.jar, import/mmapi.jar, import/nokia-ui.jar, import/wmapi.jar.
Actually only the first two libraries are needed for the sample application, but when the others are included, future enhancements are easier to accomplish.

Optionally you can change the build-settings by modifying the file "build.xml" (which is located in the root of your project).
For example you can change the deviceRequirements if you want to. The example is optimized to Nokia Series 60 devices.

You can now create the JAR and JAD files by right-clicking the build.xml file, selecting "Run Ant" and running Ant in the next dialog. You will find the JAR and JAD files then in the "dist" folder of the project. If you want to access them from within Eclipse, you might need to refresh your project:
Right-click the project and select "Refresh".

If the "Run Ant..." command is not shown, select the "build.xml" file, then open the Menu "Run" and select "External Tools" -> "Run as" -> "Ant Build".

After you have integrated the sample application into Eclipse, you will find following structure in your project (assuming that your project is called "myproject" and your workspace "workspace"):

Folder / File  Description  
workspace/sample The applications project
workspace/sample/build.xml The controller of the build process
workspace/sample/resources Folder for all resources and design descriptions of the project
workspace/sample/resources/polish.css Basic design description
workspace/sample/build Temporary build folder, will be created automatically. Should not be shared in CVS and similar systems.
workspace/sample/dist Folder for the ready-to-deploy applications. It will be created automatically. Should not be shared in CVS and similar systems.

Integrating J2ME Polish into Borland's JBuilder

To integrate J2ME Polish into JBuilder it is best to copy the sample application (the "sample" folder of your J2ME Polish installation) in your workspace. Then start JBuilder and create a new project called "sample".

In the project-dialog select the appropriate path and confirm the "src" folder as the main source-folder. Switch to the "Required Libraries" tab and select "Add..." and then "New...". Enter "MIDP-Development" or similar as the name of the library and add the files "enough-j2mepolish-client.jar", "midp2.jar", "mmapi.jar", "wmapi.jar" and "nokia-ui.jar" from the "{polish.home}/import" folder to the library path.

Note: only the first two libraries are actually needed by the sample application, but if you later want to explore the full possibilities of J2ME Polish you already have all important libraries included.

Now create the new project.

After the project has been created, you need to integrate the provided "build.xml" file: Select "Wizard" -> "Ant" -> "Add..." and select the file "build.xml" in the project-root. Now the "build.xml" is shown in the project-view. Important: you need to deactivate the Borland-compiler for building the actual applications: Right-click the "build.xml" file, select "Properties..." and de-select the "Use Borland Java compiler" check box.

You can now build the sample application by right-clicking the "build.xml" file and selecting "Make". You will find the created J2ME application files in the "dist" folder of your project, after you have switched to the "File Browser" view.

Integrating J2ME Polish with NetBeans

NetBeans 5.x

Please check out the NetBeans Module for controlling J2ME Polish from within NetBeans.
J2ME Polish provides NetBeans specific build scripts from J2ME Polish 1.3 Beta 3 onwards. You can now just open any of the provided sample applications, delete the default build.xml script and rename the build-netbeans.xml script to build.xml. You can from then on use the normal debugging, build and compile facilities of NetBeans.
Integrating a sample application in NetBeans:

  • Select File > Open Project... and select any sample application in ${polish.home}/samples. Just select a folder like the menu folder and select Open.
  • Now switch to the Files window by selecting Window > Files.
  • In this window delete or rename the build.xml script which is in the base folder of the project.
  • Now right-click the build-netbeans.xml script and rename it to build.xml. When the renaming does not work, do it directly from the file system (e.g. Windows Explorer).
  • From now on you can build, run, debug and compile with the normal NetBeans commands (e.g. F5 for debugging). J2ME Polish is then used for building etc.

When you start a new project in NetBeans, just copy one of the sample build.xml scripts to your project's folder. Then adjust the settings according to your needs.

Setup and Configuration of Ant

Ant only needs to be configured when it should be called from the command-line. Since Ant is integrated in every modern Java-IDE, you just need to right-click the "build.xml"-file in your IDE and choose "Run Ant..." (or similar).

After you have downloaded and installed Ant (http://ant.apache.org), you need to set your PATH-environment variable, so that the "ant"-command can be found. If you have installed Ant into "C:\tools\ant" then enter following command on your Windows-command-line (or your shell-script):

SET PATH=%PATH%;C:\tools\ant\bin

You can change the PATH variable permanently in the System-Settings of Windows (Control Center -> System -> Advanced -> Environment variables).

Now you need set the JAVA_HOME variable as well, e.g.:

SET JAVA_HOME=C:\j2sdk1.4.2

Under Unix/Linux/Mac OS X please use the "export" command instead of the "SET" command.

Now you should be able to issue following calls from the command-line (make sure that you are in the "sample" folder of your J2ME Polish installation):

echo Just calling ant to build and obfuscate the example:
ant

echo Now calling ant with the test-property set to true, so the build is faster:
ant test j2mepolish

Integrating J2ME Polish with an Existing Project

You can use J2ME Polish for any existing project by copying the file "sample/build.xml" as well as the "sample/resources" folder to the root-folder of the project. You then need to adjust the "build.xml" and the "resources/polish.css" files.

Here are the required steps:

  • Make sure you use the latest release (current release is J2ME Polish 2.4).
  • Copy the "sample/build.xml" and the "sample/resources" folder to your project-root.
  • Move your resources like images, sound-files etc into the "resources" folder of your project. Remember that you cannot use subfolders for resources, since subfolders are used for the automatic resource assembling of J2ME Polish.
  • Adjust the "build.xml" file: you need to specify your MIDlet class in the <midlet> element. You might also want to adjust the <deviceRequirements> element, currently applications are build for 4 device-groups:
    1) Nokia Series 60 ("Nokia/Series60"),
    2) Nokia Series 60 with MIDP/2.0 ("Nokia/Series60Midp2"),
    3) Any MIDP/1.0 phone("Generic/midp1"),
    4) Any MIDP/2.0 phone ("Generic/midp2").
  • If you want to use the J2ME Polish GUI, you need to make changes to the "resources/polish.css" file.
    Tip: use dynamic styles like "form" and "list" for a start. Have a look at the how-to explaining the first steps for using the J2ME Polish GUI.
  • If you do not want to use the J2ME Polish GUI, disable it by setting the "usePolishGui"-attribute of the <build> element to "false".
  • Ensure that your Ant-setup is correct, do you have set the JAVA_HOME environment variable?
  • Call "ant" within your project root to build your application.

If you have any problems, please drop me a line at j2mepolish@enough.de or at the forums.

back to top