Generating Java Object API Code

Use the code generation batch file to generate object API code for the SUP101 mobile application project.

Prerequisites
You must be connected to both My Sample Database and My Unwired Server. Code generation fails if the server-side (run-time) enterprise information system (EIS) data sources referenced by the MBOs in the project are not running and available to connect to when you generate object API code.
Task
  1. Optional: In Unwired WorkSpace, open the SUP101 mobile application project.
    In WorkSpace Navigator, highlight the SUP101 folder.
    Note: If you do not see the SUP101 project in Workspace Navigator, you must first complete the Tutorial: Developing Mobile Business Objects, which is a prerequisite for this tutorial.
  2. Optional: If you are performing other tutorials, add a new folder to the project in which to generate code for each device platform.
    For example, in WorkSpace Navigator, expand SUP101 and add an Android folder under Generated Code. The Generated Code directory was created during the MBO Tutorial.
  3. In Windows Explorer, locate <domain name>_package.jar in your mobile project folder. For the SUP101 example, the project is deployed to the default domain, and the deploy jar file is in the following location: C:\Documents and Settings\user\workspace\SUP101\Deployment\.pkg.profile\My_Unwired_server\default_package.jar.
  4. Make sure that the JAR file contains this file: deployment_unit.xml.
  5. Use a utility to extract the deployment_unit.xml file to another location.
  6. From <UnwiredPlatform_InstallDir>\MobileSDK\ObjectAPI\Utils\bin, run the codegen.bat utility, specifying the following parameters:
    codegen.bat -java -client -android -ulj <path>\deployment_unit.xml [-output <output_dir>] [-doc]
    • The -output parameter allows you to specify an output directory. If you omit this parameter, the output goes into the <UnwiredPlatform_InstallDir>\MobileSDK\ObjectAPI\Utils\genfiles directory, assuming codegen.bat is run from the <UnwiredPlatform_InstallDir>\MobileSDK\ObjectAPI\Utils\bin directory. You can direct the output to the Android folder you created in the optional step.
    • The -doc parameter specifies that documentation is generated for the generated code.
    Ignore these warnings:
    log4j:WARN No appenders could be found for logger ...
    log4j:WARN Please initialize the log4j system properly.