S
Stephen Kellett
Hi Folks,
History:
I'm working on a Java product for blind and partially sighted people.
The product uses a 3rd party, proprietary speech engine. We started this
project in the 1997, so we had to use native libraries (which is why we
aren't using the free Sun Speech engine). As a result, we are still
using the native interface.
Problem:
In the past I've built this native library and used it with no problems,
using VisualCafe 3.0 and JDK1.1.3. I've recently had to upgrade to
JDK1.4
(1.4.2_03 to be exact) to get access to some changes in Java
functionality. So I'm using NetBeans 3.51 with JDK1.4.
As a result I've had to rebuild my native libraries - no problem, had to
change a few library linkages, but all went fine. However when I try to
use
the libraries, the correct native library loads, but then any of the
methods
gets an Unsatisfied link error. I've tried commenting out complex
methods
leaving only the trivial methods and they fail. I've recreated the
headers
using javah only to find there is no change between the previous headers
I
used and these new ones.
Included below is the native class definition, the header file and the
java
error messages - anyone got any ideas what is going wrong. The correct
DLL is being loaded, I know that much.
I hope some of you can help. Replies by email or to the newsgroup will
be most appreciated.
Stephen
Loading native library 'SpeechIO'...
Native library 'SpeechIO' loaded.
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
java.lang.UnsatisfiedLinkError: connect
at cw.speech.SpeechIO.connect(Native Method)
at cw.speech.SpeechIO.<init>(SpeechIO.java:76)
at cw.speech.Speech.initSpeech(Speech.java:997)
at cw.speech.Speech.<init>(Speech.java:724)
at cw.wordAloud.CommandHandler.<init>(CommandHandler.java:582)
at
cw.wordAloud.LearningDisabledUI.setupCommandHandler(LearningDisabledUI.ja
va:1621)
at cw.wordAloud.Spoken.main(Spoken.java:535)
package cw.speech;
public class SpeechIO
{
public SpeechIO()
{
long id = 0;
try
{
// tell the speechio.dll where the product is installed
// note that we must convert semi colons to something else
// so that speechIO.dll's parameter parser doesn't mangle
the
// values
String str;
String dir;
str = "InstallationDirectory_";
dir = cw.wordAloud.fileLocations.getInstallationDirectory();
dir = dir.replace(':', '*');
str += dir;
// finally add a dummy value
str += ":0";
command(str, 0);
// now connect to the speechio.dll, this starts the comms
thread
// in the speechio.dll so that windows messages get serviced
id = connect();
}
catch (Exception e)
{
System.out.println("SpeechIO failed to connect to speech
engine\n");
}
//System.out.println("SpeechIO ID is " + id + ". It should be
non
zero");
}
public void finalize()
{
try
{
close();
}
catch (Exception e)
{
}
}
public native long connect();
public native void close();
public native void speak(String data,
int token);
public native void command(String data,
int token);
public native void configure(String data,
int token);
public native void convertDocToHTML(String converter,
String fileToConvert,
String outputFile,
String title);
static
{
System.out.println("Loading native library
'SpeechIO'...");
try
{
System.loadLibrary("speechio");
System.out.println("Native library 'SpeechIO'
loaded.");
}
catch(UnsatisfiedLinkError e)
{
System.out.println("Failed to load SpeechIO
library");
System.out.println(e);
}
catch(SecurityException e)
{
System.out.println("Failed to load SpeechIO
library");
System.out.println(e);
}
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class SpeechIO */
#ifndef _Included_SpeechIO
#define _Included_SpeechIO
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: SpeechIO
* Method: connect
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_SpeechIO_connect
(JNIEnv *, jobject);
/*
* Class: SpeechIO
* Method: close
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_SpeechIO_close
(JNIEnv *, jobject);
/*
* Class: SpeechIO
* Method: speak
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_speak
(JNIEnv *, jobject, jstring, jint);
/*
* Class: SpeechIO
* Method: command
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_command
(JNIEnv *, jobject, jstring, jint);
/*
* Class: SpeechIO
* Method: configure
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_configure
(JNIEnv *, jobject, jstring, jint);
// this function added by hand...
JNIEXPORT void JNICALL Java_SpeechIO_convertDocToHTML(JNIEnv *, jobject,
jstring, jstring, jstring, jstring);
#ifdef __cplusplus
}
#endif
#endif
History:
I'm working on a Java product for blind and partially sighted people.
The product uses a 3rd party, proprietary speech engine. We started this
project in the 1997, so we had to use native libraries (which is why we
aren't using the free Sun Speech engine). As a result, we are still
using the native interface.
Problem:
In the past I've built this native library and used it with no problems,
using VisualCafe 3.0 and JDK1.1.3. I've recently had to upgrade to
JDK1.4
(1.4.2_03 to be exact) to get access to some changes in Java
functionality. So I'm using NetBeans 3.51 with JDK1.4.
As a result I've had to rebuild my native libraries - no problem, had to
change a few library linkages, but all went fine. However when I try to
use
the libraries, the correct native library loads, but then any of the
methods
gets an Unsatisfied link error. I've tried commenting out complex
methods
leaving only the trivial methods and they fail. I've recreated the
headers
using javah only to find there is no change between the previous headers
I
used and these new ones.
Included below is the native class definition, the header file and the
java
error messages - anyone got any ideas what is going wrong. The correct
DLL is being loaded, I know that much.
I hope some of you can help. Replies by email or to the newsgroup will
be most appreciated.
Stephen
Loading native library 'SpeechIO'...
Native library 'SpeechIO' loaded.
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
Jan 27, 2004 12:45:52 PM java.util.jar.Attributes read
WARNING: Duplicate name in Manifest: Depends-On
java.lang.UnsatisfiedLinkError: connect
at cw.speech.SpeechIO.connect(Native Method)
at cw.speech.SpeechIO.<init>(SpeechIO.java:76)
at cw.speech.Speech.initSpeech(Speech.java:997)
at cw.speech.Speech.<init>(Speech.java:724)
at cw.wordAloud.CommandHandler.<init>(CommandHandler.java:582)
at
cw.wordAloud.LearningDisabledUI.setupCommandHandler(LearningDisabledUI.ja
va:1621)
at cw.wordAloud.Spoken.main(Spoken.java:535)
package cw.speech;
public class SpeechIO
{
public SpeechIO()
{
long id = 0;
try
{
// tell the speechio.dll where the product is installed
// note that we must convert semi colons to something else
// so that speechIO.dll's parameter parser doesn't mangle
the
// values
String str;
String dir;
str = "InstallationDirectory_";
dir = cw.wordAloud.fileLocations.getInstallationDirectory();
dir = dir.replace(':', '*');
str += dir;
// finally add a dummy value
str += ":0";
command(str, 0);
// now connect to the speechio.dll, this starts the comms
thread
// in the speechio.dll so that windows messages get serviced
id = connect();
}
catch (Exception e)
{
System.out.println("SpeechIO failed to connect to speech
engine\n");
}
//System.out.println("SpeechIO ID is " + id + ". It should be
non
zero");
}
public void finalize()
{
try
{
close();
}
catch (Exception e)
{
}
}
public native long connect();
public native void close();
public native void speak(String data,
int token);
public native void command(String data,
int token);
public native void configure(String data,
int token);
public native void convertDocToHTML(String converter,
String fileToConvert,
String outputFile,
String title);
static
{
System.out.println("Loading native library
'SpeechIO'...");
try
{
System.loadLibrary("speechio");
System.out.println("Native library 'SpeechIO'
loaded.");
}
catch(UnsatisfiedLinkError e)
{
System.out.println("Failed to load SpeechIO
library");
System.out.println(e);
}
catch(SecurityException e)
{
System.out.println("Failed to load SpeechIO
library");
System.out.println(e);
}
}
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class SpeechIO */
#ifndef _Included_SpeechIO
#define _Included_SpeechIO
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: SpeechIO
* Method: connect
* Signature: ()J
*/
JNIEXPORT jlong JNICALL Java_SpeechIO_connect
(JNIEnv *, jobject);
/*
* Class: SpeechIO
* Method: close
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_SpeechIO_close
(JNIEnv *, jobject);
/*
* Class: SpeechIO
* Method: speak
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_speak
(JNIEnv *, jobject, jstring, jint);
/*
* Class: SpeechIO
* Method: command
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_command
(JNIEnv *, jobject, jstring, jint);
/*
* Class: SpeechIO
* Method: configure
* Signature: (Ljava/lang/String;I)V
*/
JNIEXPORT void JNICALL Java_SpeechIO_configure
(JNIEnv *, jobject, jstring, jint);
// this function added by hand...
JNIEXPORT void JNICALL Java_SpeechIO_convertDocToHTML(JNIEnv *, jobject,
jstring, jstring, jstring, jstring);
#ifdef __cplusplus
}
#endif
#endif