{"__v":30,"_id":"55a93cb702becf2d007aac47","category":{"__v":6,"_id":"55a936b1cf45e1390093f362","pages":["55a936e3c8bd450d000dd1de","55a9390b4c661b3700cf4e21","55a93bd35d3abb0d0012f194","55a93cb702becf2d007aac47","55a93efb02becf2d007aac55","55a940d902becf2d007aac67"],"project":"55a7aee84a33f92b00b7a150","version":"55a7aee84a33f92b00b7a153","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-17T17:09:05.944Z","from_sync":false,"order":1,"slug":"sdks","title":"SDKs"},"parentDoc":null,"project":"55a7aee84a33f92b00b7a150","user":"55a7ae50bf1be93100d89df1","version":{"__v":6,"_id":"55a7aee84a33f92b00b7a153","project":"55a7aee84a33f92b00b7a150","createdAt":"2015-07-16T13:17:28.411Z","releaseDate":"2015-07-16T13:17:28.411Z","categories":["55a7aee94a33f92b00b7a154","55a7fefa3efe0c2f0074cbdf","55a8fb10c8bd450d000dd130","55a936b1cf45e1390093f362","55abddeaa36ccd0d00fdebe1","5624db675a86b423009462e1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-17T17:34:47.901Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":3,"body":"Clone the [Java SDK](https://github.com/AYLIEN/aylien_textapi_java) from our GitHub or use a published binary release.\n\nThe Java SDK is published to [The Maven Central Repository](http://search.maven.org/), so no additional repositories are required.\n\nUsing [**Maven**](http://maven.apache.org/index.html):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<dependency>\\n  <groupId>com.aylien.textapi</groupId>\\n  <artifactId>client</artifactId>\\n  <version>0.6.0</version>\\n</dependency>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\nUsing [**sbt**](http://www.scala-sbt.org/):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"libraryDependencies += \\\"com.aylien.textapi\\\" % \\\"client\\\" % \\\"0.6.0\\\"\",\n      \"language\": \"scala\"\n    }\n  ]\n}\n[/block]\nOr [download](http://repo1.maven.org/maven2/com/aylien/textapi/client/) directly if you're not using a dependency manager.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step by Step Guide to Building a Maven Project\"\n}\n[/block]\n1. Create a new directory\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"mkdir Demo\\ncd Demo\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n2. Create the POM file (`pom.xml`) file in it with following contents:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<project>\\n  <modelVersion>4.0.0</modelVersion>\\n  <groupId>com.example</groupId>\\n  <artifactId>aylien-textapi-sample-app</artifactId>\\n  <version>0.1.0-SNAPSHOT</version>\\n  <dependencies>\\n    <dependency>\\n      <groupId>com.aylien.textapi</groupId>\\n      <artifactId>client</artifactId>\\n      <version>0.6.0</version>\\n    </dependency>\\n  </dependencies>\\n</project>\",\n      \"language\": \"xml\",\n      \"name\": \"pom.xml\"\n    }\n  ]\n}\n[/block]\n3. Create the required Java source directories:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"mkdir -p src/main/java/com/example/\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n4. Create a new Java file named `SentimentDemo.java` with following contents in the newly created directory:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"package com.example;\\n\\nimport com.aylien.textapi.TextAPIClient;\\nimport com.aylien.textapi.parameters.*;\\nimport com.aylien.textapi.responses.*;\\n\\nclass SentimentDemo {\\n  public static void main(String[] args) throws Exception {\\n    TextAPIClient client = new TextAPIClient(\\\"[[app:id]]\\\", \\\"[[app:key]]\\\");\\n    SentimentParams.Builder builder = SentimentParams.newBuilder();\\n    builder.setText(\\\"John is a very good football player\\\");\\n    Sentiment sentiment = client.sentiment(builder.build());\\n    System.out.println(sentiment);\\n  }\\n}\",\n      \"language\": \"java\",\n      \"name\": \"SentimentDemo.java\"\n    }\n  ]\n}\n[/block]\n5. Compile and run the project\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"mvn compile\\nmvn exec:java -Dexec.mainClass=\\\"com.example.SentimentDemo\\\"\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\nYou can find examples for utilizing other endpoints in **Java** in the Endpoints section of this documentation.","excerpt":"Easiest way to get up & running with Text Analysis API in Java and JVM-based languages such as Scala, Clojure, etc.","slug":"java-sdk","type":"basic","title":"Java SDK"}

Java SDK

Easiest way to get up & running with Text Analysis API in Java and JVM-based languages such as Scala, Clojure, etc.

Clone the [Java SDK](https://github.com/AYLIEN/aylien_textapi_java) from our GitHub or use a published binary release. The Java SDK is published to [The Maven Central Repository](http://search.maven.org/), so no additional repositories are required. Using [**Maven**](http://maven.apache.org/index.html): [block:code] { "codes": [ { "code": "<dependency>\n <groupId>com.aylien.textapi</groupId>\n <artifactId>client</artifactId>\n <version>0.6.0</version>\n</dependency>", "language": "xml" } ] } [/block] Using [**sbt**](http://www.scala-sbt.org/): [block:code] { "codes": [ { "code": "libraryDependencies += \"com.aylien.textapi\" % \"client\" % \"0.6.0\"", "language": "scala" } ] } [/block] Or [download](http://repo1.maven.org/maven2/com/aylien/textapi/client/) directly if you're not using a dependency manager. [block:api-header] { "type": "basic", "title": "Step by Step Guide to Building a Maven Project" } [/block] 1. Create a new directory [block:code] { "codes": [ { "code": "mkdir Demo\ncd Demo", "language": "shell" } ] } [/block] 2. Create the POM file (`pom.xml`) file in it with following contents: [block:code] { "codes": [ { "code": "<project>\n <modelVersion>4.0.0</modelVersion>\n <groupId>com.example</groupId>\n <artifactId>aylien-textapi-sample-app</artifactId>\n <version>0.1.0-SNAPSHOT</version>\n <dependencies>\n <dependency>\n <groupId>com.aylien.textapi</groupId>\n <artifactId>client</artifactId>\n <version>0.6.0</version>\n </dependency>\n </dependencies>\n</project>", "language": "xml", "name": "pom.xml" } ] } [/block] 3. Create the required Java source directories: [block:code] { "codes": [ { "code": "mkdir -p src/main/java/com/example/", "language": "shell" } ] } [/block] 4. Create a new Java file named `SentimentDemo.java` with following contents in the newly created directory: [block:code] { "codes": [ { "code": "package com.example;\n\nimport com.aylien.textapi.TextAPIClient;\nimport com.aylien.textapi.parameters.*;\nimport com.aylien.textapi.responses.*;\n\nclass SentimentDemo {\n public static void main(String[] args) throws Exception {\n TextAPIClient client = new TextAPIClient(\"[[app:id]]\", \"[[app:key]]\");\n SentimentParams.Builder builder = SentimentParams.newBuilder();\n builder.setText(\"John is a very good football player\");\n Sentiment sentiment = client.sentiment(builder.build());\n System.out.println(sentiment);\n }\n}", "language": "java", "name": "SentimentDemo.java" } ] } [/block] 5. Compile and run the project [block:code] { "codes": [ { "code": "mvn compile\nmvn exec:java -Dexec.mainClass=\"com.example.SentimentDemo\"", "language": "shell" } ] } [/block] You can find examples for utilizing other endpoints in **Java** in the Endpoints section of this documentation.