|
||
|
|||
|
Hello,
I am getting the following error. Please advide where I may be going wrong. Exception in thread "main" java.lang.UnsatisfiedLinkError: Plcio.open(Ljava/lang/String Iat Plcio.open(Native Method) at Plcio.main(Plcio.java:11) Plcio.java Java Code
public class Plcio {
private native int open(String plcName);
static {
//System.loadLibrary("test");
System.load("/home/usr/plcioExampleslib/libtest.so");
}
public static void main(String[] args) {
Plcio plcio = new Plcio();
int result = plcio.open("virtual");
System.out.println("result = " + result);
}
}
Plc.h Java Code
#ifndef _PLC_H
#define _PLC_H
#include<iostream>
#include<string>
#include<vector>
#include<plc.h>
#include<jni.h>
typedef PLC* plcPointer;
class Plc{
public:
Plc() { }
Plc(const std::string &plctype, const std::vector<int> &data):_plctype(plctype),_data(data) {}
JNIEXPORT jint JNICALL Java_Plcio_open (JNIEnv *env, jobject jobj, jstring name) ;
private:
plcPointer _ptr;
const std::string _plctype;
std::vector<int> _data;
};
#endif
Plc.cpp Java Code
#include "Plc.h"
#include <jni.h>
using namespace std;
JNIEXPORT jint JNICALL Plc::Java_Plcio_open (JNIEnv *env, jobject jobj, jstring name) {
const char *plcname = (env)->GetStringUTFChars(name, 0);
_ptr = plc_open(const_cast<char*>(plcname));
env->ReleaseStringUTFChars(name, plcname);
if(_ptr == NULL) {
plc_print_error(_ptr, "plc_open\n");
return -1;
} else
cout << " open successfully " << endl;
return 0;
}
Regards, -H
|
|
|||
|
Look at the API for System.load:
PHP Code:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| java.lang.NullPointerException - Help | mds1256 | Exceptions | 5 | 30-11-2009 11:31 PM |
| Java.lang.reflect.invocationTargetException | varun | Exceptions | 5 | 03-11-2009 03:40 PM |
| error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Date) | ss7 | What's Wrong With My Code? | 2 | 03-11-2009 11:28 AM |
| How to reverse a String using java.lang.StringBuilder | JavaPF | Java Code Snippets and Tutorials | 0 | 22-07-2009 02:42 PM |
| [SOLVED] cannot be applied to (java.lang.String) | tazjaime | What's Wrong With My Code? | 1 | 23-04-2009 03:19 PM |