Jump to content
  • Advertisement
Sign in to follow this  
smiley_horse

[java] Is it possible to call c++ from java with CNI?.

This topic is 4911 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Looking att gcj manual (about cni section): there is not a word how to call c++ code from java program. Not a singel word or example in whole section. I have also googled pretty much around and there are several ppl offering some basic tutorials and mentioning CNI, but seems like anyone on earth suddenly want to call java from their c++ code. Also is it possible to go other way around, or I have to use JNI even when compiling with gcj? I just need some simple pointer so I can start use CNI ... if anyone has some plz handle it over.

Share this post


Link to post
Share on other sites
Advertisement
Thnks for fast anser - interesting; but it's kind-a tool for generating JNI code.

However I am looking for info about calling c++ code with CNI, if it's possible.

Share this post


Link to post
Share on other sites
GCJ is used to build native interfaces for Java. Once that is done, you just import the appropriate class file and use it like you would any other java class.

Share this post


Link to post
Share on other sites
GCJ is used to build native interfaces for Java. Once that is done, you just import the appropriate class file and use it like you would any other java class.

Oki ... can u tell me how? That's what I'm asking.

Just a simple quetion: have u ever called c++ method from your java prog with CNI?

[Edited by - smiley_horse on July 8, 2005 6:13:05 PM]

Share this post


Link to post
Share on other sites
I guess so.
________________________________________________________
However I have figured it out. I found this project and took some peek into code & makefiles: http://www.ii.uib.no/~rolfwr/jcnix, which was of help.

If anyone else is wondering, the process is:

1. create java class
2. compile java class with gcjh to produce header file
3. compile java class again with "gcjh -stubs classname" to get .cc file (optional)
4. compile .cc file with gcc as ordinary c++ file (with -c option)
5. compile java class with gcj, pass it .o file from step 4

Actually there is no difference from using jni, but they could have say that :), it could spare some wondering.

[Edited by - smiley_horse on July 9, 2005 10:28:28 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!