chinaej18 / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Exception in thread "main" java.lang.NoClassDefFoundError #128

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I am using Netbeans 6.9 IDE to compile and run my java translator program but 
every time i got the following error.
run:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
        at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:122)
        at com.google.api.translate.Translate.execute(Translate.java:69)
        at javatranslator.translator.main(translator.java:30)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 3 more
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)

Below is my program:
package javatranslator;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
public class translator{
    public static void main(String[] args){
        try{
            Translate.setHttpReferrer("117.98.212.188");
            String translatedText = Translate.execute("This is a language translator.",Language.ENGLISH, Language.HINDI);
            System.out.println(translatedText);
        }
        catch(Exception e){
            System.out.println(e.getMessage());
        }
    }
}
The ip 117.98.212.188,i got from ipconfig command.

Original issue reported on code.google.com by ravi2008...@gmail.com on 15 Feb 2011 at 7:14

GoogleCodeExporter commented 8 years ago
See the News section on the home page about depending upon the JSON library.

http://code.google.com/p/google-api-translate-java/

Original comment by rich.mid...@gmail.com on 15 Feb 2011 at 7:42