A thin Java wrapper for the Steamworks C++ API.
About
Getting started
Build instructions
Known issues
Showcase
Starting with steamworks4j v1.7.0, the SDK is required to build/package from source. Download the latest Steamworks SDK, then unzip and copy the following folders into the steamworks4j/ root directory:
Just use Maven with mvn package
in the root directory to compile a jar ready to be used in your application, or mvn install
to deploy it to your local Maven cache.
During the compile phase, the Maven build pulls shared libraries out of the sdk/redistributable_bin/ folder and adds them as resources to the steamworks4j module. For copyright reasons, this is not done for steamworks4j-server and the sdkencryptedappticket library. If you want to create such a package, this can be enforced manually with mvn package -Plibs
.
You can use these profiles to simulate the commands I use to deploy new versions:
# snapshot
mvn install -Psnapshot,libs -pl java-wrapper
mvn install -Psnapshot -pl server
# release
mvn install -Prelease,libs -pl java-wrapper
mvn install -Prelease -pl server
You do not need to build the native libraries yourself if you don’t plan to modify the native code of steamworks4j. There are prebuilt versions provided as resources of steamworks4j and steamworks4j-server.
jnigen is used to generate parts of the native code, and premake4/5 to compile native code into dynamic libraries.
Windows
steamworks4j/build-natives/
folder.Linux
Mac OS
The first step is to let jnigen generate C++ source files for the embedded JNI functions. The com.codedisaster.steamworks.jnigen.JNICodeGenerator
class in the jnigen
sub-project contains the code to do that.
steamworks4j/
root folder.JNICodeGenerator.main()
as a plain Java application from inside your favorite IDE. No arguments are required.steamworks4j/java-wrapper/src/main/native/
and steamworks4j/server/src/main/native/
.If everything is setup correctly, you now only need to run the right build-osx.sh, build-linux.sh or build-win.bat
shell script in the steamworks4j/build-natives/
folder to compile and link the native libraries on each target platform. The scripts also copy the compiled libraries to the appropriate src/main/resources/
folder.
On Windows, the build script expects an additional parameter for the compiler version to use. For example, run with build-win.bat vs2022
to compile and link using Visual Studio 2022.
In case of errors, you should be able to open the workspace/project files created by premake4/5 in their respective IDE for troubleshooting.