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