giszh86 / 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: org/json/JSONObject #115

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,
I am using the below code to convert the word test from english to dutch
and i am getting the below error
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject

Code:
package translator;
import com.google.api.translate.Language;
import com.google.api.translate.Translate;

public class Main {
  public static void main(String[] args) throws Exception {
    // Set the HTTP referrer to your website address.
      Translate.setHttpReferrer("http://localhost");
      System.out.println("1111111111111")  ; 
    String translatedText = Translate.execute("test", Language.ENGLISH, Language.DUTCH);
      System.out.println("1111111111111");
   // System.out.println(translatedText);
  }
}
I am using the latest version jar files.

Thanks,
Nagaraju D

Original issue reported on code.google.com by nagaraju...@gmail.com on 23 Dec 2010 at 4:52

GoogleCodeExporter commented 9 years ago
In the latest jar the json.org/java implementation has been separated.

Add this jar to your classpath:
http://mirrors.ibiblio.org/pub/mirrors/maven2/org/json/json/20090211/json-200902
11.jar

Or add this to your maven pom.xml depedencies:
<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20090211</version>
</dependency>

Original comment by rich.mid...@gmail.com on 23 Dec 2010 at 5:22

GoogleCodeExporter commented 9 years ago
After adding the jar you mentioed i got the below error
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version 
number in .class file
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:122)
    at com.google.api.translate.Translate.execute(Translate.java:69)

Thanks,
Nagaraju D

Original comment by nagaraju...@gmail.com on 24 Dec 2010 at 6:31

GoogleCodeExporter commented 9 years ago
Tried with different java version its working
Thanks alot for your help

Thanks,
Nagaraju D

Original comment by nagaraju...@gmail.com on 24 Dec 2010 at 6:39

GoogleCodeExporter commented 9 years ago
Thanks to this post.. The Same issue is fixed to me too..

Original comment by loganath...@gmail.com on 20 Jan 2011 at 7:43

GoogleCodeExporter commented 9 years ago
Thank you so much.. it helped me a lot

Original comment by ram.prad...@gmail.com on 13 Dec 2011 at 9:43

GoogleCodeExporter commented 9 years ago
Thank you this helped very much!

Original comment by vebradb...@gmail.com on 2 Jul 2012 at 7:57

GoogleCodeExporter commented 9 years ago
Thank you this helped very much!
 :D :D .

Original comment by r.shyams...@gmail.com on 30 Jul 2013 at 6:28

GoogleCodeExporter commented 9 years ago
Add json-xxxx.jar to the project ,all is ok! thank you !

Original comment by jiao_z...@163.com on 15 Feb 2014 at 5:44