Java code, so any calls to that code are outside of the control of the
JVM. This is why you need something like JNI - to translate the objects
and references from Java to C/C++.
The closest equivalent of the C "extern" statement is "import". It's
been a long time since I used JNI, but, as I recall, you have to
reference the C functions within a Java class, and thus you have to use
"import" on that class.
Sorry, but I've never used gcj.
-Java Guy
On 6/12/2010 2:14 PM, mike wrote:
>
> 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?
>
>
------------------------------------
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELYYahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Java_Official/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/Java_Official/join
(Yahoo! ID required)
<*> To change settings via email:
Java_Official-digest@yahoogroups.com
Java_Official-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
Java_Official-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
No comments:
Post a Comment