Last reviewed: 12/15/2024 8:25:37 AM
Java Applications
Develop Java applications that manage lexicons using your favorite Java development tools. This includes development environments such as Eclipse, IntelliJ, JDeveloper, and NetBeans.
The following sections describe the steps for integrating LexiconKit with Java applications.
JRE Configuration
LexiconKit includes Java libraries for JDK 1.8, 11, 17, and 21 to support most application's target runtime environments. If you need a specific target runtime, then contact Chant Product Support.
To access the LexiconKit Java classes within your application, add the class libraries to your JDK environment:
- copy the JLexiconKit.DLL file to your Java JDK bin directory;
- copy the applicable 32-bit speech API DLL file(s) to your Java JDK bin directory;
- copy the lexiconkit.jar and chant.shared.jar libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\lexiconkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
- copy the JLexiconKitX64.DLL file to your Java JDK bin directory;
- copy the applicable 64-bit speech API DLL file(s) to your Java JDK bin directory;
- copy the lexiconkit.jar and chant.shared.jar class libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\lexiconkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
To access the LexiconKit Java classes within your application, add references to the Chant shared and LexiconKit class libraries in your code:
import com.lexiconkit.*;
import net.chant.shared.*;
Object Instantiation
Declare a global variable for the LexiconKit class, instantiate an instance, set the credentials, and set the event handler.
public class Frame1 extends JFrame implements com.lexiconkit.JChantLexiconKitEvents
{
private JLexiconKit _LexiconKit = null;
private JSAPI5Synthesizer _Synthesizer = null;
private void jbInit() throws Exception
{
_LexiconKit = new JLexiconKit();
if (_LexiconKit != null)
{
// Set credentials
_LexiconKit.setCredentials("Credentials");
_Synthesizer = _LexiconKit.createSAPI5Synthesizer();
if (_Synthesizer != null)
{
// Optionally, set the callback object
_Synthesizer.setChantLexiconKitEvents(this);
// Optionally, register for callback
_Synthesizer.registerCallback(ChantLexiconKitCallback.CCAPIError);
}
}
}
}
LexiconKit Java applications require the lexiconkit.jar and chant.shared.jar in the target system Java JRE lib directory and/or ensure the classpath includes the path where the lexiconkit.jar and chant.shared.jar libraries are placed on your target system. The LexiconKit library (JLexiconKit.dll or JLexiconKitX64.dll) and the applicable LexiconKit Speech API library must be in the target system Java JRE bin directory.
| Speech API | LexiconKit Speech API class | LexiconKit Speech API library |
|---|---|---|
| Acapela TTS | JAcaTTSSynthesizer | CLexiconKit.AcaTTS.dll or CLexiconKitX64.AcaTTS.dll |
| Cepstral Swift | JSwiftSynthesizer | CLexiconKit.Swift.dll or CLexiconKitX64.Swift.dll |
| Microsoft Azure Speech | JMCSSynthesizer | CLexiconKit.MCS.dll or CLexiconKitX64.MCS.dll |
| Microsoft SAPI 5 | JSAPI5Recognizer or JSAPI5Synthesizer | CLexiconKit.SAPI5.dll or CLexiconKitX64.SAPI5.dll |
| Microsoft Speech Platform | JMSPRecognizer or JMSPSynthesizer | CLexiconKit.MSP.dll or CLexiconKitX64.MSP.dll |
| Microsoft WindowsMedia | JWindowsMediaRecognizer or JWindowsMediaSynthesizer | CLexiconKit.WinRT.dll or CLexiconKitX64.WinRT.dll |
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as there was an error.
// Event Handlers
public void apiError(Object sender, ChantAPIErrorEventArgs args)
{
System.out.println(
String.format("(%d) %s %s", args->getRC(), args->getFunction(), args->getMessage())
);
}
Development and Deployment Checklist
When developing and deploying Java applications, ensure you have a valid license, bundle the correct Chant class libraries, and configure your installation properly on the target system. Review the following checklist before developing and deploying your applications:
- Develop and deploy Java applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy lexiconkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the lexiconkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JLexiconKit.dll to the target system Java JRE bin directory.
- Copy applicable 32-bit LexiconKit Speech API DLL(s) to the target system Java JRE bin directory.
- Copy applicable 32-bit Microsoft Cognitive Services client DLLs to the target system Java JRE bin directory when using Azure Speech.
- Develop and deploy Java applications to any system with a valid license from Chant. See the section License for more information about licensing Chant software.
- Copy lexiconkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the lexiconkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JLexiconKitX64.dll to the target system.
- Copy applicable 64-bit LexiconKit Speech API DLL(s) to the target system Java JRE bin directory.
- Copy applicable 64-bit Microsoft Cognitive Services client DLLs to the target system Java JRE bin directory when using Azure Speech.
Sample Projects
Java sample projects are installed at the following location:
- Documents\Chant\LexiconKit 11\Java.