Install FreeTTS (A speech synthesizer written entirely in the Java) using apt-get.
sudo apt-get install freetts
Open your project in NetBeans and select to add a jar/folder to the project.
Navigate to /usr/share/java and add a reference to freetts.jar file.
You are ready to write java code to convert text to speech!