Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Integrate Java and C

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Integrate Java and C

    Hi,
    Is it possible to call a C function from Java. I need to develop Java interface which calls C functions in a daemon. The problem is that the Java and C are in different daemons. Is there a way to combine the two languages?

    Regards
    Peter


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Integrate Java and C

    There are 2 main ways to call external functions from Java: The Java Native Interface (JNI), or Java Native Access (JNA). Personally I've never worked with JNA before, but I have worked with JNI before.

    For a quick starter tutorial on JNI, see An Introduction to the Java Native Interface.

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Integrate Java and C

    Thank you for the answer! One thing I don't understand - is it doing to work if the Java code and the C code are in two different Linux daemons? Or thy must be in one folder compiled together?

  4. #4
    Junior Member
    Join Date
    Aug 2011
    Posts
    1
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Integrate Java and C

    Here is the best and simple tutorial for you

    Java native interface step by step solution

    You will also find how to configure visual studio for jni project

  5. The Following User Says Thank You to petervegas For This Useful Post:

    JavaPF (September 5th, 2011)