Java Code:
1 import javax.speech.*;

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

4 public class test {

5 public static void main(String args[]) {

6 try {

7 Synthesizer synth = Central.createSynthesizer(

8 new SynthesizerModeDesc(Locale.ENGLISH));

9 synth.allocate();

10 synth.resume();

11 synth.waitEngineState(Synthesizer.ALLOCATED);

12 synth.speakPlainText("Hello, world!", null);

13 synth.waitEngineState(Synthesizer.QUEUE_EMPTY);

14 synth.deallocate();

15 } catch (Exception e) {

16 e.printStackTrace();
17 }
18 }
19 }
I've got a very annoying problem. Basically whenever I compile the above code using javac and then try to run the CLASS file it generates, it tells me there's a null pointer exception on line 9 Synth.Allocate. I've searched all over the internet to no avail. The program is meant to speak Hello World to me. I've got Jsapi, all the jar files are in \jre6\lib\ext.

I've got speech.properties in both these locations, C:\Users\Myusername : C:\Program Files\Java\jre6\lib

I've searched the internet for hours and there are loads of posts about it, but none of them explain how to fix it. Please if you know how to fix it and get rid of this null pointer exception at line 9 could you tell me :D I would be so grateful!

Oh ye by the way I purposely put the spaces in the code to make it easier to read.