jni in JavaBean/EJB


EJB programming & troubleshooting: jni in JavaBean/EJB

  1. jni in JavaBean/EJB (7 messages)


    I need to access some hardware peripheral using RS232/RS422.
    As I know that Java is not good as C/C++ to access hardware peripheral devices.

    Is it possible to use java to call C/C++ functions to access the devices(actually,I have many functions writting in C/C++)?

    Or, is any java's api do the same thing as C/C++ to access the RS232/RS422?

    Please give me advice.

    Threaded Messages (7)

  2. jni in JavaBean/EJB[ Go to top ]

    You already have answer in your subject. JNI will help you.

  3. jni in JavaBean/EJB[ Go to top ]

    Read the specs for anything about JNI in Enterprise JavaBeans. I doubt if it's possible to make direct JNI calls from your Enterprise JavaBean. But, there are application servers that provide bridges to native systems and stuff... Have a look into that. Software AG for instance provides EJB/COM bridges and even EJB/Perl and EJB/C++ bridges I think... I woulnd't just go and implement a JNI call in my EJB I think...
  4. jni in JavaBean/EJB[ Go to top ]

    Can't even propose the project that could need JNI in EJB layer.

  5. jni in JavaBean/EJB[ Go to top ]

    I am curious to see if you actually can make native calls within an EJB. The only reference I've found in the EJB specs state that you cannot load native libraries from an EJB. It has no restrictions on making native calls. I suppose as long as you use another class or somehow instruct the EJB Container to load the native library, you should be able make a native call in your EJB.

    Please post your results if you try this!

  6. jni in JavaBean/EJB[ Go to top ]

    If it tells that you cannot load the library, that means that you'll not be able to make native calls, because the only mean you can "somehow" load library into EJB layer can be reached from EJB calls. You are working with distributed systems, do not forget that please.

  7. jni in JavaBean/EJB[ Go to top ]

    Loading a library and making a native method call are two very different things. Loading a native library makes the libraries available to the entire VM. Anything running under the VM should be able to access it, unless of course there is some security issues blocking it.

    Think about it...you're allowed to use Oracle's native OCI drivers, which means that the JDBC code included with Oracle's OCI driver is just delegating operations to a native library. You're allowed to do JDBC inside EJB's correct? Even WebLogic uses native libraries to enhance performance. I don't think being distributed makes any difference. Somewhere, your EJB instance exists in a JVM. That JVM just loads the native library and makes calls. Any system accessing that EJB instance is using a proxy anyway.

    You can get around the entire issue by creating regular classes that make native calls, and write your EJBs to make calls to your regular java classes. As far as I know, the spec has no restrictions on what kind of objects your EJB can interact with.

  8. jni in JavaBean/EJB[ Go to top ]

    You didn't catch my idea. I mean that there is no way to upload library to EJB layer without interacting with EJB directly. May be I missed the point, than tell me the way to do it.