This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes new to jsapi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "new to jsapi" Watch "new to jsapi" New topic
Author

new to jsapi

Kebede Abdi
Greenhorn

Joined: Dec 07, 2008
Posts: 11
please help how completly run jsapi in netbeans . i tried the example for speech recognition but error is displayed. Some one who try it and get expected out put help .And also how to load the grammer file. i appriciet your help. thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
Welcome to JavaRanch.

error is displayed.

What error is that? Is there a stack trace to go along with it?


Ping & DNS - my free Android networking tools app
Kebede Abdi
Greenhorn

Joined: Dec 07, 2008
Posts: 11
thanks alot! it is really amessing to get a reply soon.
the error is :
rec deallocate is unreported exception javax.speech.EngineException;mustbe caught or declared to be thrown
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

That's a compiler error. javax.speech.EngineException is a checked exception, so you should follow the instructions in the error message: catch it (try-catch block) or add it to the throws clause of your method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Kebede Abdi
Greenhorn

Joined: Dec 07, 2008
Posts: 11
thanks friends !

i fix that error with try-catch block.like this
try{
rec.deallocate();
System.exit(0);
catch(Exception ex){ex.fillInstackTrace();}

but what happened to this

public void resultAccepted(ResultEvent e)

there is red underline on resultAccepted
i ignore it and run the program but there is error on line 35 as

java.lang.NullPointerException
at javaapplication19.HelloWorld.main(HelloWorld.java:35)

My final question: before the HelloWorld example 0n the site
http://java.sun.com/products/java-media/speech/forDevelopers/jsapi-guide/Recognition.html#7408
there is a grammar and it says Place this grammar into a file
is that important if so how can i do that? i'm really new to it. If there is another information which i must know about JSAPI please help friends thanks!

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Although the problem occurs when calling jsapi, the real problem is basic Java - exception handling, missing methods, etc. Moving to JiGb
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
Please tell us exactly where you get the NullPointerException, and then go through the line and see which object references might be null.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8804
    
    5
consider making this an intermediate thread...


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
I agree with Rob that finding the location of an NPE is a beginner's topic.
Kebede Abdi
Greenhorn

Joined: Dec 07, 2008
Posts: 11
For what Campbell asks the NullPointerException is at a line rec.allocate();
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38045
    
  22
Assuming there is nothing else on the line, this suggests the rec object was null at that point.
  • Have you instantiated rec correctly? Probably in the constructor.
  • Has rec been reassigned to null?
  • Has anything been serialised and rec been lost on the way?
  • Has rec somehow been passed as null?
  • There is a good chance that you will know how to sort out the NPE when you have answered those questions.

    Then let's see whether any problems remain; if it is a JSAPI problem still, it might then be necessary to move this thread again.
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    Ok! friends i will fix it
    But please tell me how to work with JSGF and JSAPI on netbeans
    to load the grammar thanks for help!
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    hi!!
    please tell me about them!
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10171
        
        8

    Dawit,
    We have lots of forums here, arranged by category.
    To get the most of the ranch, always remember to choose a proper forum.

    Since your new question is related more to IDEs I suggest you post it here to get a better response
    Also please start a new thread for a new question.


    [How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    THANKS Maneesh and thankyou all!
    i try my best but...
    Any one who run the HelloWorld example in netbeans
    the example is on the site
    http://java.sun.com/products/java-media/speech/for...pi-guide/Recognition.html#7408
    please show me. I badly need it, after i know it well i'm going to use jsapi for another appliction .
    please from the scratch.
    Thanks for bighearted help that is why i feel free!!!
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    hello friends !!!
    i fix the NPE error by running my program on diffirent PC .

    i use You may be an all the neccerary steps for file reader

    FileReader reader = new FileReader("C:/Documents and Settings/dawi2137/Desktop/hello.gram");
    RuleGrammar gram = rec.loadJSGF(reader);

    Now i get problem on FileReader like this
    java.io.FileNotFoundException: C:\Documents and Settings\dawi2137\Desktop\hello.gram (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at java.io.FileReader.<init>(FileReader.java:41)
    at javaapplication1.HelloWorld.main(HelloWorld.java:31)
    how can i fix it?
    Maneesh Godbole
    Saloon Keeper

    Joined: Jul 26, 2007
    Posts: 10171
        
        8

    The problem is here
    java.io.FileNotFoundException: C:\Documents and Settings\dawi2137\Desktop\hello.gram (The system cannot find the file specified)


    Make sure the file exists.
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    I create the file and save in the path mentioned as hello.gram!

    And i'm sure that the file is regular file not a directory.
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    now the file is allready read but nowthe error is
    the grammar name is not specified at public what is happing
    i follow all the procedure
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 38045
        
      22
    No longer a beginner's topic.

    Moving.
    Kebede Abdi
    Greenhorn

    Joined: Dec 07, 2008
    Posts: 11
    Sorry for disterbance and THANKS A lot for being with me!
    I done it all what i need before i recieve your message . No More Biginner men just i begin it.!!!'''''''''''But........
     
    Consider Paul's rocket mass heater.
     
    subject: new to jsapi
     
    Similar Threads
    Null pointer exception in code
    JSAPI - other languages than English; MIDlet - settings loading; JSAPI - algorithm application
    Whats is modes of opeartion and mode descriptor
    Speech
    Java Speech API