Results 1 to 7 of 7
  1. #1
    mgopi is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default How to invoke a C API using Java program

    Hi

    I've a C API to be called from a JAVA program. Is that possible. If yes, please explain in detail.

    Detailed Info:
    The C API has to be tested using a testing language called TTCN3. This uses eclipse. There's some part of code that has to be written in JAVA and hence can u please tell me how to link the output of JAVA to invoke the C API.

    Thanks
    Gopi

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,252
    Blog Entries
    1
    Rep Power
    24

    Default

    Yes, kind of. You'll need to read up on how to use the Java Native Interface or JNI, and then create a small C program that conforms to the JNI standards that will allow you to bridge your C API and Java. If you Google on this, you'll find several decent tutorials.

  3. #3
    mgopi is offline Member
    Join Date
    Dec 2008
    Posts
    2
    Rep Power
    0

    Default

    Thank you very much.....I'll take a look at JNI and then post further querries.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,252
    Blog Entries
    1
    Rep Power
    24

    Default

    You're welcome. I hope that you're better versed in C/C++ than I am, because if not, then it'll be a tough slog (speaking from personal experience here!).

    Good luck!

  5. #5
    jack239 is offline Member
    Join Date
    Jul 2008
    Posts
    35
    Rep Power
    0

    Default

    Or you can use J/Invoke to call any C\C++ API or function from pure Java program. I've found they have a good tutorial on this: see it- Calling DLLs from Java | J/Invoke
    there is no need to use any JINI here.
    New to Java/PHP/Javascript development?
    For free help go to- www.techcubetalk.com

  6. #6
    2potatocakes is offline Member
    Join Date
    Sep 2008
    Posts
    43
    Rep Power
    0

    Default

    Nice link Jack! wasn't sure it was that easy ;)

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,252
    Blog Entries
    1
    Rep Power
    24

    Default

    but J/Invoke is not free but in fact costs $400. While this may be worth it if you are developing a professional product, if you're doing this for school or just messing around (or even if you are creating a professional product) it's worth your while to explore JNI, since as it's part of the standard Java libraries, it is free.

Similar Threads

  1. Invoke Applet
    By chankokchern in forum Java Applets
    Replies: 1
    Last Post: 07-29-2008, 04:35 PM
  2. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  3. Replies: 0
    Last Post: 10-04-2007, 09:33 PM
  4. Replies: 1
    Last Post: 07-06-2007, 06:08 AM
  5. Re address to jsp to that I invoke it
    By Marcus in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-09-2007, 04:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •