Java应用程序中的Microsoft Translator API

时间:2012-06-16 19:09:53

标签: java noclassdeffounderror language-translation microsoft-translator

我正在尝试在我的Java应用程序中创建Microsoft Translator API。我在Windows Azure市场注册并注册了我的Microsoft Translate应用程序,因此我有这些ClientId和Client Secret密钥,但它仍无效。

我无法找到我做错的事。

这是我的代码:

import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;

public class Main {
    public static void main(String[] args) {
        try{
            Translate.setClientId(/* my Client Id */);
            Translate.setClientSecret(/* my Client Secret */);

            String translatedText = Translate.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH);

            System.out.println(translatedText);
        }
        catch(Exception e) {
            System.err.println("Exception: " + e.getMessage());
        }
    }
} 

这就是我得到的错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONValue
at     com.memetix.mst.MicrosoftTranslatorAPI.retrieveResponse(MicrosoftTranslatorAPI.java:161)
at com.memetix.mst.MicrosoftTranslatorAPI.retrieveString(MicrosoftTranslatorAPI.java:199)
at com.memetix.mst.translate.Translate.execute(Translate.java:61)
at dictionary.mainWindow.main(mainWindow.java:27)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONValue
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 4 more
Java Result: 1

1 个答案:

答案 0 :(得分:2)