aspose file tools*
The moose likes Java in General and the fly likes How return char array from native method to Java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How return char array from native method to Java?" Watch "How return char array from native method to Java?" New topic
Author

How return char array from native method to Java?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
I have a JNI method that creates a char[] array and then will return it do the java program that called it. how do i do this? Do I have to create a jcharArray? how do I do that?
Basically what I want to do is: (pseudo code)

How would I do something like that?
Also, related:
1. Can I return a jobject (or something else) for an object of a non-"standard" class? For example, IP_ADAPTER_INFO (found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/ip_adapter_info.asp )
2. Anyone know of a really good JNI explanation site? The Sun stuff is not the best.
[ March 04, 2003: Message edited by: Robert Paris ]
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
Well, I finally figured it out. Here's the code for anyone who's interested:

That's it! However: does anyone know if there's any cleanup I need to do? Is there anything else I need to do to make sure the jbyteArray is returned but can be garbage collected later and that there are no "leaks?"
[ March 04, 2003: Message edited by: Robert Paris ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How return char array from native method to Java?