Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a C++ API in Java

I'm, currently developing a game in Java and want to publish it on Steam when it's finished. Their website says the Steam API was written in C++, and when I e-mailed them to ask whether there is a way to use the API in Java, they told me I had to write a wrapper for this

My question is: How do I write such a wrapper, or did someone else write this previously and made it available for downloading?

like image 321
Rapti Avatar asked May 02 '26 09:05

Rapti


2 Answers

The key technology you're looking for is the Java Native Interface

like image 166
Alnitak Avatar answered May 05 '26 00:05

Alnitak


You can use SWIG to automatically generate the glue code (JNI).

You need the C++ header files and can create java packages and classes
which you can use in you project.
See Swig and Java for details.

like image 42
G. Martinek Avatar answered May 04 '26 23:05

G. Martinek