I need to compile this project:
https://github.com/boatmeme/microsoft-translator-java-api
i create a project named “microsoft-translator-java-api” in eclipse and copy all of this project files starting from “com” folder into the src folder of my new project. everything OK but i have some errors that says i need a dependency library called “json-simple”, then i go to here: http://code.google.com/p/json-simple/downloads/list and download the latest version(1.1.1) and import it to my project by right click on my project and click on “build path” and then click on “add external archives” and import it on my project… every thing is OK right now and i don’t have any error…
now, i need to create a jar file. to do this i right click on my project and click on “export” then select java->jar file from list, click next, select my project and uncheck .classpath and .project on the right side panel and then click on finish and create my .jar file…
i need this file in my android project, when include this file in my project and run project i get errors. this is my logcat:
01-23 11:44:41.016: E/AndroidRuntime(285): FATAL EXCEPTION: AsyncTask #1
01-23 11:44:41.016: E/AndroidRuntime(285): java.lang.RuntimeException: An error occured while executing doInBackground()
01-23 11:44:41.016: E/AndroidRuntime(285): at android.os.AsyncTask$3.done(AsyncTask.java:200)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.lang.Thread.run(Thread.java:1096)
01-23 11:44:41.016: E/AndroidRuntime(285): Caused by: java.lang.NoClassDefFoundError: org.json.simple.JSONValue
01-23 11:44:41.016: E/AndroidRuntime(285): at com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:161)
01-23 11:44:41.016: E/AndroidRuntime(285): at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
01-23 11:44:41.016: E/AndroidRuntime(285): at com.memetix.mst.translate.Translate.execute(Translate.java:61)
01-23 11:44:41.016: E/AndroidRuntime(285): at com.memetix.MicrosoftTranslatorAndroidTestActivity$MyAsyncTask.doInBackground(MicrosoftTranslatorAndroidTestActivity.java:34)
01-23 11:44:41.016: E/AndroidRuntime(285): at com.memetix.MicrosoftTranslatorAndroidTestActivity$MyAsyncTask.doInBackground(MicrosoftTranslatorAndroidTestActivity.java:1)
01-23 11:44:41.016: E/AndroidRuntime(285): at android.os.AsyncTask$2.call(AsyncTask.java:185)
01-23 11:44:41.016: E/AndroidRuntime(285): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-23 11:44:41.016: E/AndroidRuntime(285): … 4 more
when i use pre-compiled version of “microsoft-translator-java-api” everything is ok and project works perfectly. but with my own compiled not…
you can find pre-compiled jar file here: https://github.com/downloads/boatmeme/microsoft-translator-java-api/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar
and this is my compiled file:
https://dl.dropbox.com/u/15006326/java/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar
can anybody check this and help me? i need only add Persian(fa) language in language .java file and recompile it… but it doesn’t work for me. ineed this project:
https://github.com/boatmeme/microsoft-translator-android-test
with modified language.java file only…
please help me. thanks
From the log, it can be seen that there is a
NoClassDefFoundErrorwhich means that Java cannot find a class at runtime which was available during compile time.json-simplehas been included at compile time but not at runtime. Theorg.json.simpleproject is packed inside the pre-compiled jar.So either configure Eclipse to build a runnable jar which should package the required libraries into the jar, or create a Manifest for the jar and add the dependency with the Class-Path header.
It might also be useful to use a Java Decompiler to compare the downloaded binary with your compiled jar which should give a clear indication of the differences.