Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

How to make native method wrapper?

Thread view: 
Metaphor - 23 Oct 2006 07:01 GMT
Hi all!
I want to make native code wrapper for java.
Then I found JNI, but I need more sample code.

For example, I want JNI to do following things.

1. C++ code makes file pointer.(use fopen())
2. C++ code runs JVM and make it load a class file.
3. This class writes "Hello World!" to the file pointer using fprintf()
wrapper.
4. Then control goes back to C++ code, and it close the pointer.(use
fclose())

Most important thing is that file pointer is exchanged between C++ code
and Java code.
Please give me a sample code or URL informed related things.
Gordon Beaton - 23 Oct 2006 10:14 GMT
> Most important thing is that file pointer is exchanged between C++
> code and Java code.

Why is this so important? Why can't the Java code open the necessary
file itself?

If you're just trying to learn how to use the invocation API, have a
look at the sample launcher included with your JDK.

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

Metaphor - 23 Oct 2006 11:16 GMT
> Why is this so important? Why can't the Java code open the necessary
> file itself?

File pointer is just a example.
I want to use this to control special handle that is no Java API to
control.(not file handle nor window one)

> If you're just trying to learn how to use the invocation API, have a
> look at the sample launcher included with your JDK.

Yes, I need Invocation API's example.
But is there more simple and effective sample?
Gordon Beaton - 23 Oct 2006 11:30 GMT
> I want to use this to control special handle that is no Java API to
> control.(not file handle nor window one)

If there is no Java API for the handle in question, then *every*
operation involving the handle must be done in native code, not just
creating and destroying it as your example suggests.

However this issue is completely unrelated to invocation; you don't
need your own custom launcher if this is the only problem you are
trying to solve.

> Yes, I need Invocation API's example.
> But is there more simple and effective sample?

Have a look at chapter 7:
http://java.sun.com/docs/books/jni/html/titlepage.html

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.