This discussion is archived
3 Replies Latest reply: Feb 28, 2011 11:34 AM by jschellSomeoneStoleMyAlias RSS

Design for two different JVM

838507 Newbie
Currently Being Moderated
Hi,

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.
  • 1. Re: Design for two different JVM
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    You write a communication layer. Two versions.

    Rest of your application talks only to that layer.

    During the build you build two versions of the application, picking the appropriate comm layer for each.
    otherwise we need to write our own communication logic for the java SE jvm
    Why can't you just use this for both?
  • 2. Re: Design for two different JVM
    838507 Newbie
    Currently Being Moderated
    Thanks for suggestion.

    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?
  • 3. Re: Design for two different JVM
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    user3516155 wrote:
    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.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points