9 The Java SDK provides a generic set of wrappers so you can make API calls in java.
13 * The Java SDK requires Java 6 or later
15 * The Java SDK is implemented as a maven project. Hence, you would need a working
16 maven environment to be able to build the source code. If you do not have maven setup,
17 you may find the "Maven in 5 Minutes":http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html link useful.
19 * In this document $ARVADOS_HOME is used to refer to the directory where
20 arvados code is cloned in your system. For ex: $ARVADOS_HOME = $HOME/arvados
23 h3. Setting up the environment
25 * The SDK requires a running Arvados API server. The following information
26 about the API server needs to be passed to the SDK using environment
27 variables or during the construction of the Arvados instance.
31 ARVADOS_API_TOKEN: API client token to be used to authorize with API server.
33 ARVADOS_API_HOST: Host name of the API server.
35 ARVADOS_API_HOST_INSECURE: Set this to true if you are using self-signed
36 certificates and would like to bypass certificate validations.
40 * Please see "api-tokens":{{site.baseurl}}/user/reference/api-tokens.html for full details.
43 h3. Building the Arvados SDK
47 $ <code class="userinput">cd $ARVADOS_HOME/sdk/java</code>
49 $ <code class="userinput">mvn -Dmaven.test.skip=true clean package</code>
50 This will generate arvados sdk jar file in the target directory
55 h3. Implementing your code to use SDK
57 <code class="userinput">$ARVADOS_HOME/sdk/java/ArvadosSDKJavaExample.java</code> serves as a sample
58 implementation using the SDK.
60 Please use this file to see how you would want use the SDK from your java program.
62 Also, refer to <code class="userinput">$ARVADOS_HOME/arvados/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java</code>
63 for more sample API invocation examples.
65 Below are the steps to compile and run this java program.
67 * <code class="userinput">ArvadosSDKJavaExample.java</code> creates an instance of Arvados SDK class and uses it to
68 make various <code class="userinput">call</code> requests.
70 * To compile ArvadosSDKJavaExample.java
73 $ <code class="userinput">javac -cp $ARVADOS_HOME/sdk/java/target/arvados-sdk-1.0-jar-with-dependencies.jar \
74 ArvadosSDKJavaExample.java</code>
75 This results in the generation of the ArvadosSDKJavaExample.class file
76 in the same directory as the java file
83 $ <code class="userinput">java -cp .:$ARVADOS_HOME/sdk/java/target/arvados-sdk-1.0-jar-with-dependencies.jar \
84 ArvadosSDKJavaExample</code>
89 h3. Viewing and Managing SDK logging
91 * SDK uses log4j logging
93 * The default location of the log file is
94 <code class="userinput">$ARVADOS_HOME/sdk/java/log/arvados_sdk_java.log</code>
96 * Update <code class="userinput">log4j.properties</code> file to change name and location of the log file.
100 $ <code class="userinput">nano $ARVADOS_HOME/sdk/java/src/main/resources/log4j.properties</code>
101 and modify the <code class="userinput">log4j.appender.fileAppender.File</code> property as needed.
104 $ <code class="userinput">mvn -Dmaven.test.skip=true clean package</code>
109 h3. Using the SDK in eclipse
111 * To develop in eclipse, you can use the provided <code class="userinput">eclipse project</code>
113 * Install "m2eclipse":https://www.eclipse.org/m2e/ plugin in your eclipse
115 * Set <code class="userinput">M2_REPO</code> classpath variable in eclipse to point to your local repository.
116 The local repository is usually located in your home directory at <code class="userinput">$HOME/.m2/repository</code>.
121 Window -> Preferences -> Java -> Build Path -> Classpath Variables
122 Click on the "New..." button and add a new
123 M2_REPO variable and set it to your local Maven repository
128 * Open the SDK project in eclipse
132 File -> Import -> Existing Projects into Workspace -> Next -> Browse
133 and select $ARVADOS_HOME/sdk/java