I cause function With ++ from library DLL

public class Test { public native long Connect (); static{ System.loadLibrary("spsdksw"); } public static void main(String[] args) { // TODO Auto-generated method stub Test t = new Test (); System.out.println(t.Connect()); } } 

but the compiler produces an error:

 Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.Connect()J at Test.GetLibVersion(Native Method) at Test.main(Test.java:13) 

What could be the reason ?

Page from the library description.

Connect method of the ISpRecordClientW interface

Establishes a connection with a recording program.

Syntax

 [Delphi] function Connect(Flags: Integer; const Username: WideString; const Password: WideString): Integer; [C++] long Connect(long Flags, BSTR Username, BSTR Password); 

Description

The method establishes a connection with the recording program. You need to call it before it becomes possible to call other methods of the interface. To disconnect and free occupied resources, call the Disconnect method.

Options

Flags Currently not used and must contain 0. Username Username. Currently not used and must contain an empty string. Password User password. Currently not used and must contain an empty string. Return value

If the method is successful and the connection is established, then the return value is SPR_S_OK. If the connection has already been made, then the return value is SPR_S_FALSE.

If the connection fails, the method returns an error code:

 SPR_E_CLIENTSOCKETOPEN SPR_E_SPRECORDPRGNOTFOUND SPR_E_ACCESS_DENIED SPR_E_CONNECT_LIMIT SPR_E_SOCKETOPEN SPR_E_LIBVERSION SPR_E_USERNAMEORPASSWORD 

Remarks

In order for the connection to be established, select the Settings item in the main menu of the administration shell, select the Program tab in the General tab, select the Program tab in the General tab and select the Allow connection of the notification library check box.

Allowed no more than 1024 simultaneous connections including connections interface ISpRecordChannelClientW.

  • Comments are not intended for extended discussion; conversation moved to chat . - Nick Volynkin

1 answer 1

Most likely, you have taken a library written in C ++ and not intended for use with the JNI (Java Native Interface), so your simple example does not work. To do this, you need to write another DLL library - the JNI layer, where the description will be in the correct format of the exported functions ( an example of using JNI ).

Actually, the exception java.lang.UnsatisfiedLinkError arises from the fact that the description of the native function in the JNI format was not found.

Alternatively, you can use JNA (Java Native Access). JNA allows you to get away with writing this layer directly in the Java class, which is much simpler ( getting started with JNA ).


If the library you are using is third-party / purchased, then perhaps the developer (or some enthusiast) has provided for its use in Java and can provide a JNI interface.