Right, it’s easier to match name but you can override the name (convention over configuration)
It’s a example from my raknet wrapper (where I keep original name):
[java]
package raknet;
import java.nio.ByteBuffer;
import com.googlecode.javacpp.;
import com.googlecode.javacpp.annotation.;
@Properties({
@Platform(value=“linux-x86_64”, include=“javacpp-code.h”, link = “RakNetDLL”),
@Platform(value=“windows-x86_64”, include=“javacpp-code.h”, link = “RakNet_VS2008_DLL_Release_x64”),
@Platform(value=“macosx-x86_64”, include=“javacpp-code.h”, link = “RakNetDLL”)
})
@Namespace(“RakNet”) // Namespace where all c++ code must reside
// “link” tells javacpp which original library should be linked (if not specified, “Abc” will be used)
public class RakNet {
static { Loader.load(); }
public static class RakPeerInterface extends Pointer {
static { Loader.load(); }
public static native RakPeerInterface GetInstance(); // Method we want to use
public static native void DestroyInstance(RakPeerInterface v); // Method we want to use
public native void Startup(int maxConnections, SocketDescriptor socketDescriptors, int socketDescriptorCount, int threadPriority);
public native void SetMaximumIncomingConnections(int maxConnections);
public native Packet Receive();
//…
[/java]
I include the native lib into the jar following a javacpp convention
src/main/resources
└── raknet
├── javacpp-code.h
├── linux-x86_64
│ └── libRakNetDLL.so
├── macosx-x86_64
│ └── libRakNetDLL.dylib
└── windows-x86_64
└── RakNet_VS2008_DLL_Release_x64.dll
more src/main/resources/raknet/javacpp-code.h
#include "RakPeerInterface.h"
#include "MessageIdentifiers.h"
#include "BitStream.h"
#include "RakNetTypes.h"
then I can use it like
[java]
public class RakNetDemo {
static final byte ID_GAME_MESSAGE_1= ID_USER_PACKET_ENUM+1;
public static void main(String[] args) {
System.out.println("BEGIN");
RakPeerInterface peer = RakPeerInterface.GetInstance();
boolean isClient = (System.getProperty("client") != null);
if (isClient) {
SocketDescriptor sd = new SocketDescriptor();
peer.Startup(1, sd, 1, -99999);
peer.Connect("127.0.0.1", 60000, null, 0);
System.out.println("Client");
[/java]
${JAVA_HOME}/bin/java \
-cp $HOME/.m2/repository/com/googlecode/javacpp/javacpp/0.7/javacpp-0.7.jar:target/raknet_java-0.1.0-SNAPSHOT.jar:target/test-classes \
sandbox.RakNetDemo
Hope, it helps