2525: More tests
[arvados.git] / sdk / java / README
1 == Arvados Java SDK
2
3   - Using the Arvados Java SDK, you can access API server from a java program.
4
5   - Please refer to http://doc.arvados.org/api/index.html for a complete list
6     of supported resources and methods.
7
8   - This document highlights the details as to how to use the SDK.
9
10   - The Java SDK is used as a maven project. Hence, you would need a working
11       maven environment to be able to build the source code.
12
13       If you do not have maven setup, you may find the following link useful.
14
15       http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
16
17   - In this document <ARVADOS_HOME> is used to refer to the directory where
18       arvados code is cloned in your system.
19       For ex: <ARVADOS_HOME> = $HOME/arvados
20
21
22 == Setting up the environment
23
24   - The SDK requires a running Arvados API server. The information about the
25           API server needs to be passed to the SDK using environment variables.
26           
27   - The following two environment variables are required by the SDK
28
29       ARVADOS_API_TOKEN, ARVADOS_API_HOST
30       
31       Below are examples using a .bashrc file:
32       
33         export ARVADOS_API_TOKEN=z40gplmla6i58rsg96jhg5u41ewdl5rj4g1py2xg6s6e2lsc3
34                 export ARVADOS_API_HOST=localhost:3001
35       
36   - You can also set ARVADOS_API_HOST_INSECURE to true if you are using
37           self-signed certificates and want to bypass certificate validations.
38
39       Below is an example using a .bashrc file:
40       
41         export ARVADOS_API_HOST_INSECURE=true
42         
43
44 == Building the Arvados SDK
45
46   - cd <ARVADOS_HOME/sdk/java
47
48   - mvn clean package
49
50       This will generate arvados sdk jar file in the target directory
51
52
53 == Implementing your code to use SDK
54
55   - <ARVADOS_HOME>/sdk/java/ArvadosSDKJavaExample.java serves as an example
56       implementation using the java SDK. Please use this file to see how
57       you would want use the SDK from your java program.
58       The steps below use this java class name.
59
60   - ArvadosSDKJavaExample.java creates an instance of Arvados SDK class and
61       uses it to make various "call" requests.
62
63   - To compile ArvadosSDKJavaExample.java
64
65       javac -cp <ARVADOS_HOME>/sdk/java/target/arvados-sdk-1.0-jar-with-dependencies.jar ArvadosSDKJavaExample.java
66
67       This results in the generation of the ArvadosSDKJavaExample.class file
68         in the same directory as the java file
69
70   - To run the class file
71
72       java -cp .:<ARVADOS_HOME>/sdk/java/target/arvados-sdk-1.0-jar-with-dependencies.jar ArvadosSDKJavaExample
73
74
75 == Viewing and managing SDK logging
76
77   - SDK uses log4j logging
78
79   - The default location of the log file is
80       <ARVADOS_HOME>/sdk/java/log/arvados_sdk_java.log
81
82   - Update log4j.properties file to change name and location of the log file.
83
84       Modify the "log4j.appender.fileAppender.File" property in log4j.properties
85         file located at <ARVADOS_HOME>/sdk/java/src/main/resources
86
87       Rebuild by running "mvn clean package"
88
89
90 == Using the SDK in eclipse
91
92   - To develop in eclipse, you can use the SDK eclipse project.
93
94   - Install "m2eclipse" plugin in your eclipse
95
96   - Open the SDK project.
97
98       File -> Import -> Existing Projects into Workspace -> Next -> Browse
99           and select <ARVADOS_HOME>/sdk/java