Skip to main content
gamedev.net
🔒 Locked

C++ classes in Java

Started by Last Attacker Feb 23, 2005 at 1:40 AM 2 replies 350+ views
Original Post
Last Attacker
Last Attacker
Hi, I'm wondering if it is at all possible to make a C++ class, compile to a DLL file and import that DLL file in Java and use that class? I know that you can definately do it with C++ functions but is classes at all possible? Thanks
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Skizz
Skizz
You need to use the Java Native Interface, or JNI for short. A quick google for JNI turns up several references to get you started.

Skizz
Last Attacker
Last Attacker
Thanks Skizz, I got something from Javaworld after googling for it.
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog
Last Attacker
Last Attacker
I have tried that tutorial on JavaWorld but is was for an older (older than 1.4) version. The reason it didn't worked was because it required a Preamble-something.h file (which they said was part of the JDK) but I didn't have it. So I tried searching on google again but still didn't find what I was looking for.

Basically I understand how to make C/C++ functions available in Java but does the classes work on the same principle?
Basically I found a part at Sun's site that showed me how to do the C++ functions thing. http://java.sun.com/docs/books/tutorial/native1.1/stepbystep/index.html

Thanks
"Take delight in the Lord and He will give you your heart's desires" - Psalm 37:4My Blog

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.