I would like to design my java application which will run on both java SE & ME jvm. This application will be invoked by the c++ using JNI. Actually all business logic is in the JAVA application and c++ will do the JNI communication for the same. However here only JNI communication layer will be different for both SE and ME jvms, other wise rest of the modules will remain same for both JVMs. Actually some proprietary JNI communication module is in place for java ME which we need to use when same application will be run on the java ME otherwise we need to write our own communication logic for the java SE jvm. How can I design java application so that it will be compatible for both the JVMs.
Here I need to use different API for both the JVMs, I mean we have some API available for ME version e.g. API for encryption/decryption, Random numbers, debugging and same can not work for SE version. We will going to use these API in our business logic. I mean if we need to do encryption/decryption in ME version then we need to use provided API else if we are using SE jvm then we need to use JCA API for the same. So How can I design the application?
So How can I design the application?
I believe I already answered that - use a communication layer.
If you are asking (different than your original question) about how your communication layer might implement similar functionality using different APIs supported by the VM then the same basic idea applies - provide a layer, code to the layer and implement the layer different for each platform.
Note however that it is foolhardy to carry this to an extreme. Don't wrap trivial functionality to gain minimal gains because it increases complexity and thus maintenance costs.