FileDocCategorySizeDatePackage
MIDletAppImageGeneratorBase.javaAPI DocphoneME MR2 API (J2ME)3971Wed May 02 18:00:06 BST 2007com.sun.midp.main

MIDletAppImageGeneratorBase

public class MIDletAppImageGeneratorBase extends Object
This class is designed to provide the functionality needed for generating the binary image from the MIDlet suite classes.

Fields Summary
Constructors Summary
Methods Summary
protected static booleangenerateAppImage(java.lang.String jarFile, java.lang.String binFile, int flags)
Creates an application image file. It loads the Java classes from the jarFile into the heap, verify the class contents, and write the classes to an Application Image file as specified by binFile.

param
jarFile - source JAR file to create binary image from
param
binFile - output file, where binary image should be stored
param
flags - flags, can be JVM.REMOVE_CLASSES_FROM_JAR
return
true if application image was generated successfully, false otherwise

        int code = 0;        
        String[] classpath  = new String[0]; // IMPL NOTE: specify the set of
                                             // dynamic libs as well
        String[] mainArgs   = new String[3];
        mainArgs[0] = jarFile;
        mainArgs[1] = binFile;
        mainArgs[2] = String.valueOf(flags);
          	        
        try {
            // IMPL NOTE: eliminate the hardcoded string constants
            Isolate iso =  new Isolate("com.sun.midp.main.AppImageWriter",
  			            mainArgs, classpath);
            iso.setAPIAccess(true);
            iso.start();
            iso.waitForExit();

            code = iso.exitCode();
        }
        catch (IsolateStartupException ise) {
            if (Logging.REPORT_LEVEL <= Logging.ERROR) {
                Logging.report(Logging.ERROR, LogChannels.LC_AMS,
                "Cannot startup isolate: " + ise);
            }            
        }
        return code == 0;