Ich kämpf gerade mit JNI rum und irgendwie will das gerade nicht so wie ich es will.
Die Bibliothek lief, bis ich eine 2. Methode eingebaut hab. Seitdem kann ich sie nicht mehr überreden zu funktionieren.
static
{
System.loadLibrary("Application");
}
public WindowsApplication()
{
// System.getProperties().list(System.out);
systemtraymenu = SystemTray.getDefaultSystemTray();
}
public native String getUserSaveDir();
public native String getSystemSaveDir();
C++ Datei
#include <shlobj.h>
#include "WindowsInfos.h"
//#include "stdafx.h"
//#ifdef __cplusplus
//extern "C" {
//#endif
JNIEXPORT jstring JNICALL Java_de_eagleside_util_application_WindowsXPApplication_getUserSaveDir
(JNIEnv * env, jobject){
TCHAR path[255];
SHGetFolderPath( NULL, CSIDL_LOCAL_APPDATA,
NULL, 0, path );
return env->NewStringUTF(path);
}
JNIEXPORT jstring JNICALL Java_de_eagleside_util_application_WindowsXPApplication_getSystemSaveDir
(JNIEnv *env, jobject){
TCHAR path[255];
SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA,
NULL, 0, path );
return env->NewStringUTF(path);
}
//#ifdef __cplusplus
//}
//#endif
Header
#include <jni.h>
/* Header for class de_eagleside_util_application_WindowsApplication */
#ifndef _Included_de_eagleside_util_application_WindowsApplication
#define _Included_de_eagleside_util_application_WindowsApplication
#ifdef __cplusplus
extern "C" {
#endif
#undef de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_DISABLE
#define de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_DISABLE 0L
#undef de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_DO_NOTHING
#define de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_DO_NOTHING 1L
#undef de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_PARSE_ARGUMENTS
#define de_eagleside_util_application_WindowsApplication_SINGLETON_APPLICATION_PARSE_ARGUMENTS 2L
/*
* Class: de_eagleside_util_application_WindowsApplication
* Method: getUserSaveDir
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_de_eagleside_util_application_WindowsApplication_getUserSaveDir
(JNIEnv *, jobject);
/*
* Class: de_eagleside_util_application_WindowsApplication
* Method: getSystemSaveDir
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_de_eagleside_util_application_WindowsApplication_getSystemSaveDir
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
Achja und das alles läuft auf Windows und soll mit VS6 kompiliert werden.