New to this; completely lost.

90 views
Skip to first unread message

Tictoon

unread,
Jun 11, 2012, 2:25:11 PM6/11/12
to microsoft-translator-java-api
Hi, I'm trying to use this API for a school coding project, but I
really don't know where to start.

I think you're supposed to put the Jar file in the application's
folder but this is a school computer so instead, I tried running the
java program we use (DrJava) with the -cp command and pointed it to
the directory where I had the .jar file stored. that didn't work, I
still got an import error when running the quickstart file from the
main page. After that I tried pointing the -cp command to the actual
jar file; still no luck

I've asked my teacher, but he doesn't know and hasn't been able to
find out, so I'm hoping I can get some input from here?

please and thank you,

Tictoon

Jonathan Griggs

unread,
Jun 13, 2012, 2:02:14 PM6/13/12
to microsoft-tran...@googlegroups.com
Hello Tictoon -

Assume this local directory structure:

[your project directory]
    |
    ---- lib 
    |
    ----com
         |
         -----mypackage
               |
               ------MySource.java

Here are some steps you can take:

  1. Register for a clientId and clientSecret with Microsoft's Windows Azure Marketplace as described here: Documentation (follow only the first 2 steps)
  2. Download the latest jar with dependencies from here: http://microsoft-translator-java-api.googlecode.com/files/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar
  3. Move the jar into [Your Project Directory]/lib
  4. Ensure that you are setting the following two properties in your source code (MySource.java):
  5.          Translate.setClientId("YOUR_CLIENT_ID");
  6.          Translate.setClientSecret("YOUR_CLIENT_SECRET");
  7. From your project root, execute the following commands
  8.         javac com/mypackage/MySource.java -classpath lib/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar;
  9.         java -cp lib/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar;  com.mypackage.Mysource 
I hope that is enough help to get you up and running. Good luck on your school project!

-jonathan

Jonathan

unread,
Jun 13, 2012, 2:05:10 PM6/13/12
to microsoft-tran...@googlegroups.com
FYI, #9 has a capitalization typo w/r/t MySource. If you were cutting and pasting, it should be:

        java -cp lib/microsoft-translator-java-api-0.6.1-jar-with-dependencies.jar;  com.mypackage.MySource  
Reply all
Reply to author
Forward
0 new messages