aspose file tools*
The moose likes Beginning Java and the fly likes Java Native Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Native Interface" Watch "Java Native Interface" New topic
Author

Java Native Interface

John Chong
Greenhorn

Joined: Jan 18, 2001
Posts: 16
May I know what is Java Native Interface? Is it a package? If yes how do I import the package? Are there any methods that I can use? If com2 port is already windows settings for use with the mouse, what connectors behind the PC can I still use to control hardware?
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

The Java Native Interface isn't a package, it's more like a specification. It describes a technique for allowing the JVM to connect a Java method call to some C/C++ library code on the local system.
The reserved word native, when used in a method declaration, tells the JVM that the method outsources its execution to some shared object library (.so file in Unix) or dynamic link library (DLL) in Windows.
The Java side might look like this:
The JDK provides a tool, javah, that will read the .class file and produce a C-style header file. The header declares the function prototypes used to write the C code and then create the .so or .dll file from it.
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

you might want to check out "Thinking in Java" one of the appendixes gives examples of using JNI http://www.bruceeckel.com

SCJP
Visit my download page
John Chong
Greenhorn

Joined: Jan 18, 2001
Posts: 16
Man, this is sounding like a song that Harry Belafonte did at Carnegi with Odetta but I can't remember the name exactly. It's either "Dear Liza" or "My bucket's got a hole" or something to that effect. In any, Belafonte sings something about my bucket has a hole in it, what shall I do? Liza replies: "Fix it!Dear Henry etc. where upon he replies "How do I fix it?". Everytime she gives him an answer he asks another question. The song goes one stanza after another and it's funny. But this isn't.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Oh. Well, ok: JNI is something you use to make Java code work with C code.
Sahir Shah
Ranch Hand

Joined: Nov 05, 2000
Posts: 158
Chong,
The song goes like this.
There's a hole in the bucket dear Liza, dear Liza , dear Liza.
Then fix it dear Henry, dear Henry, dear Henry.
With what shall I fix it dear Liza, dear Liza , dear Liza ?
With straw dear Henry, dear Henry, dear Henry.
But the straw is too long dear Liza, dear Liza , dear Liza.
Then cut it dear Henry, dear Henry, dear Henry.
With what shall I cut it dear Liza, dear Liza , dear Liza.
With a knife dear Henry, dear Henry, dear Henry.
But the knife is too blunt dear Liza, dear Liza , dear Liza.
Then whet it dear Henry, dear Henry, dear Henry.
With what shall I whet it dear Liza, dear Liza , dear Liza.
With a stone dear Henry, dear Henry, dear Henry.
But the stone is too dry dear Liza, dear Liza , dear Liza.
Then wet it dear Henry, dear Henry, dear Henry.
Whith what shall I wet it dear Liza, dear Liza , dear Liza.
With water dear Henry, dear Henry, dear Henry.
How do I fetch water dear Liza, dear Liza , dear Liza.
In a bucket dear Henry, dear Henry, dear Henry.
But there is a hole in the bucket dear Liza, dear Liza , dear Liza.
Its more than thirty years since I sang this song on speech day at my boarding school. I hope I have got the words more or less right. Pretty awesome memory, if I may say so myself. Eh Chong?
Cheers
Sahir
[This message has been edited by Sahir Shah (edited March 21, 2001).]


....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Native Interface
 
Similar Threads
Threads
Don't know if its art, but I need to know!
Declaring a native as final
Native XML parser.
Native code?