File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes native keyword ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "native keyword ?" Watch "native keyword ?" New topic

native keyword ?

Sam Doder
Ranch Hand

Joined: Feb 06, 2008
Posts: 204
Ok , I have used the native keyword in java alot when I use the JNI.
What I am trying to understand is if I can use native keyword the same way as c uses extern.
But not having to create a dll or anything just simple load an existing dll and using a particular function in it by looking up that functions mangled name using something like objdump,...etc

The only thing I could see being a problem is if their is parameters to the function.... problems with the type ,size ,...etc with this.
But if the parameters corresponded to the same thing as java parameters then would it work?

Also using gcj to compile java into machine code. If I used the native command would it work like extern to be resolved be the linker ... enabling me to call c/c++ from compiled java into .o files so I can call c without a user defined dll or interface like JNI CNI ,...etc

Anybody know?
What exactly the keyword native gets compiled down to when in a class file and how the JVM translates this into machine code?

basically I have c .o files with functions in them that I would like to call from java. gcj allows me to compile the java into .o files as well and then link to an .exe with all those c .o files. But I want away to call the c function from the java functions in the .exe. I know calling java from c would be as easy as looking up the names with objdump and putting an extern command in my c files before I compile them into .o files. My problem is how to call c from java .o files normal I would use native command and go thru a library but now I am linking to an exe file so all I need is the native command to beable to call back c functions???

That is why I am wanting to know how native works?
I agree. Here's the link:
subject: native keyword ?