How to detect if a Class/Package is available on the phone
This article shows how to determine at runtime whether a particular optional Java ME class or API is available on the device.
Article Metadata
We can use the dynamic instantiation method, like this:
boolean MMAPIAvailable;
try {
// Try to instantiate a class using a string as the Class name
// so, the SDK without the API can compile the application
Class.forName("javax.microedition.media.Player").newInstance();
// If the next code is executed, then the API is available
MMAPIAvailable = true;
} catch ( ClassNotFoundException e) {
MMAPIAvailable = false;
}


This is the way things should work, unfortunately in practice many phone refuse to even run the midlet if any reference to a non supported API is included.
If any phone supports an api and if we don't know then this code will help to find api in phone.so it will help to intermediatery to find the api that a perticular MIDP and CLDC version supports.
--vkmunjpara 16:43, 14 September 2009 (UTC)