Java Native Interface - Quickie


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Java Native Interface - Quickie

  1. #1
    John Senford Guest

    Java Native Interface - Quickie


    This is just a quick question/suggestion request....if you know about JNI
    that is:

    My Java program calls a C function (in a DLL).
    The result of the C function is several Strings.

    How would you best go about communicating these strings back to the Java
    program?

    They do not have to be done all at once; one string can be passed to the
    java program at a time, if necessary.

    thanks.

    ADDITIONAL:
    -----------
    Would/Could you:
    a) simply pass the string back as the return value (how do you converting
    the C char array into a jstring)

    b) pass the C char array back as the return value (how do you convert and
    pass arrays as a return value)

    c) place the C array contents directly into a char array in the java program
    (how do you convert C char element into a Java char element)

    d) ...the list goes on....

    John.

  2. #2
    Paul Clapham Guest

    Re: Java Native Interface - Quickie

    See the tutorial at
    http://java.sun.com/docs/books/tutor...1.1/index.html

    John Senford <johnsenford@hotmail.com> wrote in message
    news:3922b1e2$1@news.devx.com...
    >
    > This is just a quick question/suggestion request....if you know about JNI
    > that is:
    >
    > My Java program calls a C function (in a DLL).
    > The result of the C function is several Strings.
    >
    > How would you best go about communicating these strings back to the Java
    > program?
    >
    > They do not have to be done all at once; one string can be passed to the
    > java program at a time, if necessary.
    >
    > thanks.
    >
    > ADDITIONAL:
    > -----------
    > Would/Could you:
    > a) simply pass the string back as the return value (how do you converting
    > the C char array into a jstring)
    >
    > b) pass the C char array back as the return value (how do you convert and
    > pass arrays as a return value)
    >
    > c) place the C array contents directly into a char array in the java

    program
    > (how do you convert C char element into a Java char element)
    >
    > d) ...the list goes on....
    >
    > John.




  3. #3
    John Senford Guest

    Re: Java Native Interface - Quickie


    Thanks for you response Paul.

    I've already looked at that tutorial and it doesn't seem to cover what I
    need. What it basically says is "if you want to work with strings then there
    are lots of functions to help you but I'm not going to tell you WHAT they
    are or HOW to use them."

    That tutorial seems more of an introduction to JNI, and I already know how
    to use JNI (generally). My problem is a more specific one than just "How
    it works..."

    I supose what I really need is a complete reference to the JNI functions
    rather than a tutorial....but where to get one from?!?!?!

    Any suggestions out there?

    John

    "Paul Clapham" <pclapham@core-mark.com> wrote:
    >See the tutorial at
    >http://java.sun.com/docs/books/tutor...1.1/index.html
    >
    >John Senford <johnsenford@hotmail.com> wrote in message
    >news:3922b1e2$1@news.devx.com...
    >>
    >> This is just a quick question/suggestion request....if you know about

    JNI
    >> that is:
    >>
    >> My Java program calls a C function (in a DLL).
    >> The result of the C function is several Strings.
    >>
    >> How would you best go about communicating these strings back to the Java
    >> program?
    >>
    >> They do not have to be done all at once; one string can be passed to the
    >> java program at a time, if necessary.
    >>
    >> thanks.
    >>
    >> ADDITIONAL:
    >> -----------
    >> Would/Could you:
    >> a) simply pass the string back as the return value (how do you converting
    >> the C char array into a jstring)
    >>
    >> b) pass the C char array back as the return value (how do you convert

    and
    >> pass arrays as a return value)
    >>
    >> c) place the C array contents directly into a char array in the java

    >program
    >> (how do you convert C char element into a Java char element)
    >>
    >> d) ...the list goes on....
    >>
    >> John.

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center