JNI : Get java.lang.UnsatisfiedLinkError
JNI : Get java.lang.UnsatisfiedLinkError
这个问题已经被问了好几次,得到了不同的回答。但他们都不适合我。
我已经从我的项目中制作了一个jni dll,用于64x windows 7中使用eclipse和jdk1.7.0_10(64位)。但加载DLL后,我得到java.lang.UnsisfiedLinkError。
我开始根据这个指南创建一个helloworld项目。它说什么我都做。但我已经得到这个错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: test.HelloWorld.print()V
at test.HelloWorld.print(Native Method)
at test.HelloWorld.main(HelloWorld.java:24)
是的,我已经包含了库路径,我已经为x64构建了C项目
代码:
package test;
public class HelloWorld {
public native void print(); //native method
static //static initializer code
{
try{
System.loadLibrary("CLibHelloWorld");
}
catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.n" + e);
System.exit(1);
}
}
public static void main(String[] args)
{
HelloWorld hw = new HelloWorld();
hw.print(); // ==> i get error on this line
}
}
和
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class HelloWorld */
#ifndef _Included_HelloWorld
#define _Included_HelloWorld
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: HelloWorld
* Method: print
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_HelloWorld_print
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
和
#include "HelloWorld.h"
#include "jni.h"
#include "stdio.h"
JNIEXPORT void JNICALL Java_HelloWorld_print(JNIEnv *env, jobject obj)
{
printf("Hello worldn");
return;
}
test.HelloWorld.print
的C名称是
Java_test_HelloWorld_print
您缺少_test
-是否使用默认包中的类运行javah?
您错过了包名称测试您应该在c 中包含您的包名称
相关文章:
- D-lang being faster than C++?
- java.lang.IndexOutOfBoundsException with JNA
- Android Studio 3.1.2 - 无法运行C++子例程"No implementation found for Java.lang.String..."
- java.lang.UnsatisfiedLinkError: Abc.greetings()V
- java.lang.Field 等效于 c++ 中
- 为什么日食总是发生错误"An internal error occurred during: "通知选择侦听器". java.lang.StackOverflowError"
- 新闻组 comp.lang.c++.moderated 死了吗?
- java.lang.UnsatisfiedLinkError:未找到实现
- JNI GetMethodID 调用,带有挂起的异常 java.lang.ClassNotFoundException
- java.lang.UnsatisfiedLinkError: dlopen failed: 无法加载"libPrivateSsl.so"所需的库"libcrypto.so.1.0.0";
- 单元测试环境中的"java.lang.UnsatisfiedLinkError: *.so: Can't find dependent libraries"
- JNI 代码返回字符串,但得到错误 java.lang.UnsatisfiedLinkError: com.packag
- 如何在没有System32的情况下解决"java.lang.UnsatisfiedLinkError:找不到依
- C++ Prog Lang 书第 139 页,例如
- JNA从DLL调用C++对象-java.lang.IollegalArgumentException:Structure
- 线程中的异常 "main" java.lang.UnsatisfiedLinkError: no JNTIest in java.library.path
- jni java.lang.unsatisfiedlinkerror,无法链接方法
- 从WordCount Hadoop示例调用Helloworld Jni函数,给出错误Java.lang.unsatisf
- 在hadoop 2.7.4的自定义排序类中调用C函数,给出Java.lang.unsatisfiedlinkerror
- 在运行时获得Java.lang.unsatisfiedlinkerror