8784: Fix test for latest firefox.
[arvados.git] / doc / sdk / java / index.html.textile.liquid
1 ---
2 layout: default
3 navsection: sdk
4 navmenu: Java
5 title: "Installation"
6 ...
7
8 The Java SDK provides a generic set of wrappers so you can make API calls in java.
9
10 h3. Introdution
11
12 * The Java SDK requires Java 6 or later
13
14 * The Java SDK is implemented as a maven project. Hence, you would need a working
15 maven environment to be able to build the source code. If you do not have maven setup,
16 you may find the "Maven in 5 Minutes":http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html link useful.
17
18 * In this document $ARVADOS_HOME is used to refer to the directory where
19 arvados code is cloned in your system. For ex: $ARVADOS_HOME = $HOME/arvados
20
21
22 h3. Setting up the environment
23
24 * The SDK requires a running Arvados API server. The following information
25           about the API server needs to be passed to the SDK using environment
26           variables or during the construction of the Arvados instance.
27
28 <notextile>
29 <pre>
30 ARVADOS_API_TOKEN: API client token to be used to authorize with API server.
31
32 ARVADOS_API_HOST: Host name of the API server.
33
34 ARVADOS_API_HOST_INSECURE: Set this to true if you are using self-signed
35     certificates and would like to bypass certificate validations.
36 </pre>
37 </notextile>
38
39 * Please see "api-tokens":{{site.baseurl}}/user/reference/api-tokens.html for full details.
40
41
42 h3. Building the Arvados SDK
43
44 <notextile>
45 <pre>
46 $ <code class="userinput">cd $ARVADOS_HOME/sdk/java</code>
47
48 $ <code class="userinput">mvn -Dmaven.test.skip=true clean package</code>
49   This will generate arvados sdk jar file in the target directory
50 </pre>
51 </notextile>
52
53
54 h3. Implementing your code to use SDK
55
56 * The following two sample programs serve as sample implementations using the SDK.
57 <code class="userinput">$ARVADOS_HOME/sdk/java/ArvadosSDKJavaExample.java</code> is a simple program
58         that makes a few calls to API server.
59 <code class="userinput">$ARVADOS_HOME/sdk/java/ArvadosSDKJavaExampleWithPrompt.java</code> can be
60         used to make calls to API server interactively.
61
62 Please use these implementations to see how you would use the SDK from your java program.
63
64 Also, refer to <code class="userinput">$ARVADOS_HOME/arvados/sdk/java/src/test/java/org/arvados/sdk/java/ArvadosTest.java</code>
65 for more sample API invocation examples.
66
67 Below are the steps to compile and run these java program.
68
69 * These programs create an instance of Arvados SDK class and use it to
70 make various <code class="userinput">call</code> requests.
71
72 * To compile the examples
73 <notextile>
74 <pre>
75 $ <code class="userinput">javac -cp $ARVADOS_HOME/sdk/java/target/arvados-sdk-1.1-jar-with-dependencies.jar \
76 ArvadosSDKJavaExample*.java</code>
77 This results in the generation of the ArvadosSDKJavaExample*.class files
78 in the same directory as the java files
79 </pre>
80 </notextile>
81
82 * To run the samples
83 <notextile>
84 <pre>
85 $ <code class="userinput">java -cp .:$ARVADOS_HOME/sdk/java/target/arvados-sdk-1.1-jar-with-dependencies.jar \
86 ArvadosSDKJavaExample</code>
87 $ <code class="userinput">java -cp .:$ARVADOS_HOME/sdk/java/target/arvados-sdk-1.1-jar-with-dependencies.jar \
88 ArvadosSDKJavaExampleWithPrompt</code>
89 </pre>
90 </notextile>
91
92
93 h3. Viewing and Managing SDK logging
94
95 * SDK uses log4j logging
96
97 * The default location of the log file is
98   <code class="userinput">$ARVADOS_HOME/sdk/java/log/arvados_sdk_java.log</code>
99
100 * Update <code class="userinput">log4j.properties</code> file to change name and location of the log file.
101
102 <notextile>
103 <pre>
104 $ <code class="userinput">nano $ARVADOS_HOME/sdk/java/src/main/resources/log4j.properties</code>
105 and modify the <code class="userinput">log4j.appender.fileAppender.File</code> property as needed.
106
107 Rebuild the SDK:
108 $ <code class="userinput">mvn -Dmaven.test.skip=true clean package</code>
109 </pre>
110 </notextile>
111
112
113 h3. Using the SDK in eclipse
114
115 * To develop in eclipse, you can use the provided <code class="userinput">eclipse project</code>
116
117 * Install "m2eclipse":https://www.eclipse.org/m2e/ plugin in your eclipse
118
119 * Set <code class="userinput">M2_REPO</code> classpath variable in eclipse to point to your local repository.
120 The local repository is usually located in your home directory at <code class="userinput">$HOME/.m2/repository</code>.
121
122 <notextile>
123 <pre>
124 In Eclipse IDE:
125 Window -> Preferences -> Java -> Build Path -> Classpath Variables
126     Click on the "New..." button and add a new
127     M2_REPO variable and set it to your local Maven repository
128 </pre>
129 </notextile>
130
131
132 * Open the SDK project in eclipse
133 <notextile>
134 <pre>
135 In Eclipse IDE:
136 File -> Import -> Existing Projects into Workspace -> Next -> Browse
137     and select $ARVADOS_HOME/sdk/java
138 </pre>
139 </notextile>