Go Back   Java Programming Forums > Java Standard Edition Programming Help > Java Native Interface


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 27-01-2010, 03:10 PM
H P H P is offline
Junior Member
 

Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
H P is on a distinguished road
Default java.lang.UnsatisfiedLinkError

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/StringI
at 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



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 27-01-2010, 03:28 PM
copeg's Avatar
Moderator
 
7 Highscores

Join Date: Oct 2009
Posts: 667
Thanks: 8
Thanked 145 Times in 137 Posts
copeg will become famous soon enoughcopeg will become famous soon enough
Default Re: java.lang.UnsatisfiedLinkError

Look at the API for System.load:
PHP Code:
Throws:
    
UnsatisfiedLinkError - if the file does not exist
Verify the path and file name you are trying to load /home/usr/plcioExampleslib/libtest.so
Reply With Quote
  #3 (permalink)  
Old 27-01-2010, 03:32 PM
H P H P is offline
Junior Member
 

Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
H P is on a distinguished road
Default Re: java.lang.UnsatisfiedLinkError

Thank you for your reply. I am certain that the path exists and the library is present in the path.

Regards,

-H
Reply With Quote
  #4 (permalink)  
Old 28-01-2010, 09:04 AM
Freaky Chris's Avatar
Senile Half-Wit
 

Join Date: Mar 2009
Location: UK
Posts: 621
Thanks: 2
Thanked 64 Times in 60 Posts
Freaky Chris will become famous soon enoughFreaky Chris will become famous soon enoughFreaky Chris will become famous soon enough

I'm feeling Cheerful
Default Re: java.lang.UnsatisfiedLinkError

Java Code
(env)->GetStringUTFChars(name, 0);
Becomes

Java Code
(env)->GetStringUTFChars(env, name, null);
Chris
__________________
chris[at]javaprogrammingforums[dot]com

University of Wales, Bangor
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
java.lang.NullPointerException - Help mds1256 Exceptions 5 30-11-2009 10:31 PM
Java.lang.reflect.invocationTargetException varun Exceptions 5 03-11-2009 02: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 10: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


100 most searched terms
Search Cloud
2d arraylist java actionlistener actionlistener in java actionlistener java addactionlistener addactionlistener in java addactionlistener java applications of oops could not create java virtual machine xp double format java double to int double to int java double to integer in java double to integer java eclipse shortcut keys eclipse tutorial for beginners exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double java get mouse position java java 2d arraylist java actionlistener java addactionlistener java convert list to map java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming help java sendkeys java two dimensional arraylist java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics two dimensional arraylist java writing ipod apps

All times are GMT. The time now is 07:21 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.