I am working to launch Amazon Mechanical Turk in Java.
This is the link for the project. (mturk-rest-java-1.0.zip can be downloaded at the bottom of the site)
http://aws.amazon.com/code/Amazon-Mechanical-Turk/581
When I unzip and am trying to Run the Sample with the following steps:
-
Update the MTGettingStarted.java file to include your access identifiers.
-
Compile the example by entering the following command:
javac *.java -
Run the example by entering the following command:
java MTGettingStarted
Compilation will give the following errors:
./src/com/amazon/mturk/requester/RESTResponse.java:23: package org.apache.xpath does not exist
import org.apache.xpath.*;
^
./src/com/amazon/mturk/requester/RESTResponse.java:108: cannot find symbol
symbol : variable XPathAPI
location: class src.com.amazon.mturk.requester.RESTResponse
str = XPathAPI.eval(doc, xpathString).toString();
^
./src/com/amazon/mturk/requester/RESTResponse.java:125: cannot find symbol
symbol : variable XPathAPI
location: class src.com.amazon.mturk.requester.RESTResponse
NodeList nl = XPathAPI.selectNodeList(doc, xpathString);
^
./src/com/amazon/mturk/requester/Utils.java:3: package org.apache.commons.codec.binary does not exist
import org.apache.commons.codec.binary.*;
^
./src/com/amazon/mturk/requester/Utils.java:58: cannot find symbol
symbol : variable Base64
location: class src.com.amazon.mturk.requester.Utils
signature = new String(Base64.encodeBase64(rawHmac));
^
Note: ./src/com/amazon/mturk/requester/RESTResponse.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors
Also, I cannot run the MTGettingStarted.java provided
Exception in thread "main" java.lang.NoClassDefFoundError: MTGettingStarted/java
Caused by: java.lang.ClassNotFoundException: MTGettingStarted.java
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)
How can I solve the problem? Sorry that I am quite a beginner in Java.
Many Thanks
The commands are missing classpath specification. Try compiling it with:
And, then, run with: