|
1 | | -Rosette API Java Examples |
2 | | -========================= |
3 | | - |
4 | | -Each example class can be run independently. |
5 | | - |
| 1 | +## Endpoint Examples |
6 | 2 | Each example file demonstrates one of the capabilities of the Rosette Platform. |
7 | 3 |
|
8 | | -A note on prerequisites. Rosette API only suports TLS 1.2 so ensure your toolchain also supports it. |
9 | | - |
10 | | -## Maven ## |
11 | | -If you use Maven, everything should have been setup and you can start running the examples using `mvn exec:java`. |
12 | | -Otherwise you can compile and run these examples by hand: |
13 | | - |
14 | | -- make sure you have JRE 1.7+, verify by `java -version` |
15 | | -- download <TODO: nexus url> |
16 | | -- `cd src/main/java/com/basistech/rosette/examples` |
17 | | -- `javac -cp .:<path-to-rosette-api-jar-file> *.java` |
18 | | -- `java -cp .:<path-to-rosette-api-jar-file> -Drosette.api.key=<your-api-key> com.basistech.rosette.examples.<XyzExample>` |
19 | | - |
20 | | -## Docker ## |
21 | | -Docker files can be found [here](https://github.com/rosette-api/java/tree/master/examples/docker) |
22 | | - |
23 | | -### Summary |
24 | | -To simplify the running of the Java examples, the Dockerfile will build an image and install the rosette-api library from the *published source*. |
25 | | - |
26 | | -### Basic Usage |
27 | | -Build the docker image, e.g. `docker build --rm -t basistech/java:1.1 .` |
28 | | - |
29 | | -Run an example as `docker run --rm -e API_KEY=api-key -v "path-to-java-dir:/source" basistech/java:1.1` |
30 | | - |
31 | | -To test against a specific source file, add `-e FILENAME=filename` before the `-v`. |
32 | | -To test against an alternate url, add `-e ALT_URL=alternate_url`. |
| 4 | +Here are some methods for running the examples. Each example will also accept an optional `-Drosette.api.altUrl` |
| 5 | +parameter for overriding the default URL. |
33 | 6 |
|
| 7 | +A note on prerequisites. Rosette API only supports TLS 1.2 so ensure your toolchain also supports it. |
34 | 8 |
|
| 9 | +#### Running from Local Source |
35 | 10 |
|
| 11 | +``` |
| 12 | +git clone [email protected]:rosette-api/java.git |
| 13 | +cd java |
| 14 | +mvn compile |
| 15 | +cd examples |
| 16 | +mvn exec:java -Dexec.mainClass="com.basistech.rosette.examples.PingExample" -Drosette.api.key=$API_KEY |
| 17 | +``` |
0 commit comments