Last reviewed: 3/23/2024 11:52:42 AM
Java Applications
Develop Java applications that manage conversations 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 VoiceXMLKit with Java applications.
JRE Configuration
VoiceXMLKit includes Java libraries for JDK 1.8, 11, 17, and 21 to support most applications' target runtime environments. If you need a specific target runtime, then contact Chant Product Support.
To access the VoiceXMLKit Java classes within your application, add the class libraries to your JDK environment:
- copy the JVoiceXMLKit.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 voicexmlkit.jar and chant.shared.jar libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\voicexmlkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
- copy the JVoiceXMLKitX64.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 voicexmlkit.jar and chant.shared.jar class libraries to your Java JDK lib; and
- append a path reference for your Java JDK lib\voicexmlkit.jar and lib\chant.shared.jar paths as a classpath property in your system settings.
To access the VoiceXMLKit Java classes within your application, add references to the Chant shared and VoiceXMLKit class libraries in your code:
import com.voicexmlkit.*;
import net.chant.shared.*;
Object Instantiation
Declare a global variable for the VoiceXMLKit class, instantiate an instance, set the credentials, and set the event handler.
public class Frame1 extends JFrame implements com.voicexmlkit.JChantVoiceXMLKitEvents
{
private JVoiceXMLKit _VoiceXMLKit = null;
private JSAPI5VoiceXML _VoiceXML = null;
private JSAPI5Recognizer _Recognizer = null;
private JSAPI5Synthesizer _Synthesizer = null;
private void jInit() throws Exception
{
// Create VoiceXMLKit object
_VoiceXMLKit = new JVoiceXMLKit();
if (_VoiceXMLKit != null)
{
// Set credentials
_VoiceXMLKit.setCredentials("Credentials");
// Create VoiceXML
_VoiceXML = _VoiceXMLKit.createSAPI5VoiceXML();
// Create recognizer
_Recognizer = _VoiceXMLKit.createSAPI5Recognizer();
// Create synthesizer
_Synthesizer = _VoiceXMLKit.createSAPI5Synthesizer();
// Set the callback
_VoiceXML.setChantVoiceXMLKitEvents(this);
// Register Callbacks
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDone);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMCompileError);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgAddChoice);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgClearChoices);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgClearText);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgCreateDialog);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgHideChoices);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgHideDialog);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgHideText);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgSelectChoice);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgSetPrompt);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgSetText);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgShowChoices);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgShowDialog);
_VoiceXML.registerCallback(ChantVoiceXMLKitCallback.CCXMDlgShowText);
}
}
}
VoiceXMLKit Java applications require the voicexmlkit.jar and chant.shared.jar in the target system Java JRE lib directory and/or ensure the classpath includes the path where the voicexmlkit.jar and chant.shared.jar libraries are placed on your target system. The VoiceXMLKit library (JVoiceXMLKit.dll or JVoiceXMLKitX64.dll) and the applicable VoiceXMLKit Speech API library must be in the target system Java JRE bin directory.
Speech API | VoiceXMLKit Speech API class | VoiceXMLKit Speech API library |
---|---|---|
Microsoft SAPI 5 | JSAPI5Recognizer or JSAPI5Synthesizer | CVoiceXMLKit.SAPI5.dll or CVoiceXMLKitX64.SAPI5.dll |
Microsoft Speech Platform | JMSPRecognizer or JMSPSynthesizer | CVoiceXMLKit.MSP.dll or CVoiceXMLKitX64.MSP.dll |
Event Callbacks
Event callbacks are the mechanism in which the class object sends information back to the application such as compilation is complete or there was an error.
public void done(Object sender, VxmlDoneEventArgs args)
{
if ((args != null) && (args.getVariables() != null))
{
...
}
}
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 voicexmlkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the voicexmlkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JVoiceXMLKit.dll to the target system Java JRE bin directory.
- Copy applicable 32-bit VoiceXMLKit Speech API DLL(s) to the target system Java JRE bin directory.
- 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 voicexmlkit.jar and chant.shared.jar to the target system Java JRE lib directory and/or ensure the classpath includes the path where the voicexmlkit.jar and chant.shared.jar libraries are placed on your target system.
- Copy JVoiceXMLKitX64.dll to the target system.
- Copy applicable 64-bit VoiceXMLKit Speech API DLL(s) to the target system Java JRE bin directory.
Sample Projects
Java sample projects are installed at the following location:
- Documents\Chant\VoiceXMLKit 7\Java.