I'm wanting to make a voice controlled program,
But when I type: 'import javax.speech' into NetBeans it says that
'javax.speech' doesn't exist.

I then downloaded Free TTS, copied the speech.properties like
I was supposed to. It still is showing the error. I did some more
research and found a place that told me to use WinZip on the jsapi.jar
file. I did.

It is still showing the error. I don't know where to put the javax
folder I now have. I tried putting it in the 'lib' folder of my 'jre6' folder.
I have also heard of Sphinx4 for this, any advice?

Anyone who could help me in this area I would be very grateful to them!!


6 Years
Discussion Span
Last Post by Asif_12

You should not have to unzip the jar. Have you added it to the Compile libraries in your Project Properties > Libraries tab?


Amazing how such a vast and seemingly hopeless problem can
have such a simple, ten second solution.

Thank you very much!

Now, almost all of the errors are gone, only one has stayed behind.

Here is the code:

import javax.speech.*;
import javax.speech.synthesis.*;
import java.util.Locale;

public class Speech {
	public static void main(String args[]) {
		try {
			// Create a synthesizer for English
			Synthesizer synth = Central.createSynthesizer(
				new SynthesizerModeDesc(Locale.ENGLISH));

			// Get it ready to speak

			// Speak the "Hello world" string
			synth.speakPlainText("Hello, world!", null);

			// Wait till speaking is done

			// Clean up
		} catch (Exception e) {

On line 1 NetBeans says 'Incorrect Package'. But all of the other errors
are gone!

Any idea what I can do to fix this?

And thanks again for the great advice!!!
It helped me exponentially!



The package declaration needs to match the directory structure of classes.

If you had a base directory called src , a class in a child directory src/ui , you would need a package declaration package ui; . A class in src/ui/main would be declare package ui.main; So depending on the directory structure of your source code base, you may need to add or adjust the package declarations.


package does not exist in my case. I have done the above resolution still it says does not exist.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.