🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.java.programmer
Article #322

Yet another JNI problem

#322
From: Editions Vigdor
Date: Mon, 03 Aug 1998 00:00
116 lines
2924 bytes
Hi !

I am encoutering a problem with JNI. I am trying to program a class that

would allow Java to access the W95/WNT Registry base and it seems that

the Java part of the program doesn't find the methods inside my dll :



Java source code :



package com.vigdor.vector;

public class Registres {

//Constants [skipped]..

  public Registres() {

         super();
	try {

         System.loadLibrary("Registres");
	} (catch Exception e) {
	 System.out.println("Erreur ! :"+e.getMessage())
	}

  }

    public native long setKey(int mainKey, String subKey, String entree,

String classe, String valeur);

    public native String getKey(int mainKey, String subKey, String

entree, String defaut);

}



C++ source code :



#include "com_vigdor_vector_Registres.h"

#include "winreg.h"

#include <windows.h>

#include <stdlib.h>



JNIEXPORT jlong JNICALL Java_com_vigdor_vector_Registres_setKey

  (JNIEnv *env, jobject obj, jint jMainKey, jstring jSubKey, jstring
jClasse, jstring jEntry, jstring jValue) {

//blah blah blah

	return(RegCloseKey(currentKey));

};



JNIEXPORT jstring JNICALL Java_com_vigdor_vector_Registres_getKey

  (JNIEnv *env, jobject obj, jint jMainKey, jstring jSubKey, jstring
jEntree, jstring jDefaut) {

//blah blah blah

  	return env-> NewStringUTF(retour);

};



The code compiles (with CodeWarrior 3) to a 1 kb Registres.dll. The java
code seems to find this dll (i.e. no UnsatisfiedLinkException during the
initialization) but as soon as I try to use either setKey or getKey, an
UnsatisfiedLinkException is thrown without message.
I have tried putting Registres.dll in the directories Windows,
Windows\System, Windows\System32, in the directory of the .class files
and in the directory of the final output file. 


Does anyone have an idea ?
Thanks in advance,
  David

-- 

�ditions

  num�riques scientifiques et universitaires

    VIGDOR



exploration de textes

    par ordinateur



http://www.vigdor.com

    contact@vigdor.com
Technical Details
Message-ID: <35C59F50.F364A41C@vigdor.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10a146,afeb4629d7eb96b,start
X-Google-Attributes: gid10a146,public
X-Google-Thread: 1089d0,afeb4629d7eb96b,start
X-Google-Attributes: gid1089d0,public
X-Google-Thread: 113ae9,afeb4629d7eb96b,start
X-Google-Attributes: gid113ae9,public
X-Google-Thread: f74b3,afeb4629d7eb96b,start
X-Google-Attributes: gidf74b3,public
From: Editions Vigdor <contact@vigdor.com>
Subject: Yet another JNI problem
Date: 1998/08/03
Message-ID: <35C59F50.F364A41C@vigdor.com>
X-Deja-AN: 377450147
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=iso-8859-1
Organization: Editions Vigdor
Mime-Version: 1.0
Reply-To: contact@vigdor.com
Newsgroups: comp.lang.java.programmer,comp.lang.java.help,borland.public.jbuilder.java.language,borland.public.jbuilder.java.api