com.github.ramanrajarathinam:native-utils

A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usualy contain implementation of some methods in native code (using JNI - Java Native Interface).

Лицензия

Лицензия

Категории

Категории

Native Инструменты разработки
Группа

Группа

com.github.ramanrajarathinam
Идентификатор

Идентификатор

native-utils
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

com.github.ramanrajarathinam:native-utils
A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usualy contain implementation of some methods in native code (using JNI - Java Native Interface).
Ссылка на сайт

Ссылка на сайт

https://github.com/RamanRajarathinam/native-utils
Система контроля версий

Система контроля версий

https://github.com/RamanRajarathinam/native-utils

Скачать native-utils

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.ramanrajarathinam/native-utils/ -->
<dependency>
    <groupId>com.github.ramanrajarathinam</groupId>
    <artifactId>native-utils</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.ramanrajarathinam/native-utils/
implementation 'com.github.ramanrajarathinam:native-utils:1.0.0'
// https://jarcasting.com/artifacts/com.github.ramanrajarathinam/native-utils/
implementation ("com.github.ramanrajarathinam:native-utils:1.0.0")
'com.github.ramanrajarathinam:native-utils:jar:1.0.0'
<dependency org="com.github.ramanrajarathinam" name="native-utils" rev="1.0.0">
  <artifact name="native-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.ramanrajarathinam', module='native-utils', version='1.0.0')
)
libraryDependencies += "com.github.ramanrajarathinam" % "native-utils" % "1.0.0"
[com.github.ramanrajarathinam/native-utils "1.0.0"]

Зависимости

test (1)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12

Модули Проекта

Данный проект не имеет модулей.

Native Utils

A simple library class which helps with loading dynamic libraries stored in the JAR archive. These libraries usualy contain implementation of some methods in native code (using JNI - Java Native Interface).

Notes

  • The temporary file is stored into temp directory specified by java.io.tmpdir (by default it’s the operating system’s temporary directory). It should be automatically deleted when the application exits.
  • Although the code has some try-finally section (to be sure that streams are closed properly in case an exception is thrown), it does not catch exceptions. The exception has to be handled by the application. I belive this approach is cleaner and has some benefits.

Usage

To load the dynamic library, just make sure it is packed inside the JAR archive and call method loadLibraryFromJar:

import cz.adamh.NativeUtils;
 
public class HelloJNI {  
    static {   
        try {    
            NativeUtils.loadLibraryFromJar("/resources/libHelloJNI.so");   
        } catch (IOException e) {
            // This is probably not the best way to handle exception :-)    
            e.printStackTrace();
        }    
    }  
 
    public native void hello();    
}

More information

More information can be found in accompanying blog post.

Версии библиотеки

Версия
1.0.0