When you use a third-party library in your application, your JAR will expand by the size of the third-party library. You can use an obfuscator to reduce the code size, and a good obfuscator will even eliminate whatever parts of the library you are not using. Even with the use of an obfuscator, a third-party library will probably still be larger than your own custom code, carefully written from scratch. You have to evaluate the tradeoff between reducing your development time and the size of your MIDlet suite JAR.

3.6.1Third-Party Libraries for One Project

Any library files placed in your project’s lib directory will be included in the building and packaging of your project. Libraries should be JAR or Zip files of Java classes.

For example, if you installed the J2ME Wireless Toolkit in C:\WTK22 and your application is called Tiny, the class library would go in C:\WTK22\apps\Tiny\lib. When you build, run, debug, and package your project, the class files in the lib directory are used.

3.6.2Third-Party Libraries for All Projects

Some devices have libraries available to all installed MIDlet suites. A manufacturer, for example, can make additional APIs available on all their devices. In this case, you want to be able to use these libraries when you build and test your application. You don’t want the libraries to be included in your packaged MIDlet suite because you will be installing the MIDlet suite on devices where the library is already present.

You can accomplish this by placing libraries in the {toolkit}\apps\lib directory. For example, if you installed the J2ME Wireless Toolkit in C:\WTK22, you would place the class libraries in C:\WTK22\apps\lib. Libraries in this directory are available for all projects.

3.7Configuring KToolbar

KToolbar includes some advanced configuration options. You can use these options by editing the {toolkit}\wtklib\{platform}\ktools.properties file. To see the effects of your changes, restart KToolbar.

26 J2ME Wireless Toolkit User’s Guide • October 2004

Page 38
Image 38
Sun Microsystems J2ME Configuring KToolbar, Third-Party Libraries for One Project, Third-Party Libraries for All Projects