本文整理了Java中com.sun.jna.Native.extractFromResourcePath()
方法的一些代码示例,展示了Native.extractFromResourcePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Native.extractFromResourcePath()
方法的具体详情如下:
包路径:com.sun.jna.Native
类名称:Native
方法名:extractFromResourcePath
[英]Attempt to extract a native library from the current resource path, using the current thread context class loader.
[中]尝试使用当前线程上下文类加载器从当前资源路径提取本机库。
代码示例来源:origin: net.java.dev.jna/jna
/** Attempt to extract a native library from the current resource path,
* using the current thread context class loader.
* @param name Base name of native library to extract. May also be an
* absolute resource path (i.e. starts with "/"), in which case the
* no transformations of the library name are performed. If only the base
* name is given, the resource path is attempted both with and without
* {@link Platform#RESOURCE_PREFIX}, after mapping the library name via
* {@link NativeLibrary#mapSharedLibraryName(String)}.
* @return File indicating extracted resource on disk
* @throws IOException if resource not found
*/
public static File extractFromResourcePath(String name) throws IOException {
return extractFromResourcePath(name, null);
}
代码示例来源:origin: net.java.dev.jna/jna
try {
String libName = "/com/sun/jna/" + Platform.RESOURCE_PREFIX + "/" + System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib");
File lib = extractFromResourcePath(libName, Native.class.getClassLoader());
if (lib == null) {
if (lib == null) {
代码示例来源:origin: net.java.dev.jna/jna
File embedded = Native.extractFromResourcePath(libraryName, (ClassLoader)options.get(Library.OPTION_CLASSLOADER));
try {
handle = Native.open(embedded.getAbsolutePath(), openFlags);
代码示例来源:origin: org.elasticsearch/jna
/** Attempt to extract a native library from the current resource path,
* using the current thread context class loader.
* @param name Base name of native library to extract. May also be an
* absolute resource path (i.e. starts with "/"), in which case the
* no transformations of the library name are performed. If only the base
* name is given, the resource path is attempted both with and without
* {@link Platform#RESOURCE_PREFIX}, after mapping the library name via
* {@link NativeLibrary#mapSharedLibraryName(String)}.
* @return File indicating extracted resource on disk
* @throws IOException if resource not found
*/
public static File extractFromResourcePath(String name) throws IOException {
return extractFromResourcePath(name, null);
}
代码示例来源:origin: games647/LagMonitor
private void extractJNI(Path jnaPath) throws IOException {
URLClassLoader jnaLoader = new URLClassLoader(new URL[]{jnaPath.toUri().toURL()});
String libName = "/com/sun/jna/" + com.sun.jna.Platform.RESOURCE_PREFIX
+ '/' + System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib");
com.sun.jna.Native.extractFromResourcePath(libName, jnaLoader);
}
代码示例来源:origin: com.squareup.jnagmp/jnagmp
private static void loadLibGmp() {
try {
// Explicitly try to load the embedded version first.
File file = Native.extractFromResourcePath("gmp", LibGmp.class.getClassLoader());
load(file.getAbsolutePath());
return;
} catch (Exception ignored) {
} catch (UnsatisfiedLinkError ignored) {
}
// Fall back to system-wide search.
load("gmp");
}
代码示例来源:origin: square/jna-gmp
private static void loadLibGmp() {
try {
// Explicitly try to load the embedded version first.
File file = Native.extractFromResourcePath("gmp", LibGmp.class.getClassLoader());
load(file.getAbsolutePath());
return;
} catch (Exception ignored) {
} catch (UnsatisfiedLinkError ignored) {
}
// Fall back to system-wide search.
load("gmp");
}
代码示例来源:origin: org.elasticsearch/jna
try {
String libName = "/com/sun/jna/" + Platform.RESOURCE_PREFIX + "/" + System.mapLibraryName("jnidispatch").replace(".dylib", ".jnilib");
File lib = extractFromResourcePath(libName, Native.class.getClassLoader());
if (lib == null) {
if (lib == null) {
代码示例来源:origin: jitsi/libjitsi
= Native.extractFromResourcePath(
"/" + Platform.RESOURCE_PREFIX + "/" + libname,
classLoader);
代码示例来源:origin: org.elasticsearch/jna
File embedded = Native.extractFromResourcePath(libraryName, (ClassLoader)options.get(Library.OPTION_CLASSLOADER));
try {
handle = Native.open(embedded.getAbsolutePath(), openFlags);
内容来源于网络,如有侵权,请联系作者删除!