{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Guides","type":"markdown"},"seo":{"title":"Java SDK Data Import","description":"Treasure AI Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasure.ai","lang":"en-US","jsonLd":{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://www.treasure.ai/","name":"Treasure AI","url":"https://www.treasure.ai/","logo":"https://www.treasure.ai/hubfs/assets/images/logos/primary-logo.svg"},{"@type":"WebSite","@id":"https://docs.treasure.ai/#website","name":"Treasure AI Documentation","url":"https://docs.treasure.ai/","inLanguage":["en","ja"],"publisher":{"@id":"https://www.treasure.ai/"}}]},"llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"java-sdk-data-import","__idx":0},"children":["Java SDK Data Import"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can import the data from your Java applications, using Treasure Data’s Java SDK."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of Java."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of Maven2."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of Treasure Data."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Java 6 or higher (for local testing)."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"install-td-logger-java-library","__idx":2},"children":["Install td-logger-java Library"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Add the following lines to your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pom.xml"]},". Replace ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["myVersion"]}," with your version. The logger library’s version information can be found in ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-logger-java/blob/master/CHANGES.txt"},"children":["CHANGES.txt"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"xml","header":{"controls":{"copy":{}}},"source":"<dependencies>\n  ...\n  <dependency>\n    <groupId>com.treasuredata</groupId>\n    <artifactId>td-logger</artifactId>\n    <version>myVersion</version>\n  </dependency>\n  ...\n</dependencies>\n","lang":"xml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you need an all-in-one jar file, we provide one at https://repo1.maven.org/maven2/com/treasuredata/."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"modify-your-app","__idx":3},"children":["Modify Your App"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The td-logger-java library comes with a built-in library for recording in-app events. Insert the following code to record events from your app. Further details regarding the event logger API can be found in the GitHub repository ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/treasure-data/td-logger-java"},"children":["td-logger-java"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["YOUR_API_KEY"]}," should be your actual apikey string. You can retrieve your API key from the Treasure Console."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"import com.treasure_data.logger.TreasureDataLogger;\npublic class Main {\n  private static TreasureDataLogger LOG;\n  static {\n    try {\n      Properties props = System.getProperties();\n      props.load(Main.class.getClassLoader().getResourceAsStream(\"treasure-data.properties\"));\n      LOG = TreasureDataLogger.getLogger(\"production\");\n    } catch (IOException e) {\n      // do something\n    }\n  }\n  public void doApp() {\n    Map<String, Object> data = new HashMap<String, Object>();\n    data.put(\"from\", \"userA\");\n    data.put(\"to\", \"userB\");\n    LOG.log(\"follow\", data);\n  }\n}\n\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your event-logging code should be placed near its corresponding event-generating code."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When using the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td-logger-java"]}," library, the posted records are buffered in the memory locally at first, and the data is uploaded every 5 minutes. Because a dedicated thread uploads the data into the cloud, it doesn’t affect your application’s response time."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The local buffer also has a size limit. If the local data exceeds this limit, the records will be uploaded immediately."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"confirming-data-import","__idx":4},"children":["Confirming Data Import"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The data gets uploaded every 5 minutes. You can confirm the data import from Treasure Console or CLI."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["From Treasure Console"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To confirm that your data has been uploaded successfully, check your dataset from the Treasure Console."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["From CLI"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Issue the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["td tables"]}," command if you have the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://docs.treasuredata.com/tools/cli-and-sdks/td-toolbelt"},"children":["TD Toolbelt"]}," CLI."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"td tables\n+------------+------------+------+-----------+\n| Database   | Table      | Type | Count     |\n+------------+------------+------+-----------+\n| production | follow     | log  | 1         |\n+------------+------------+------+-----------+\n"},"children":[]}]},"headings":[{"value":"Java SDK Data Import","id":"java-sdk-data-import","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Install td-logger-java Library","id":"install-td-logger-java-library","depth":2},{"value":"Modify Your App","id":"modify-your-app","depth":2},{"value":"Confirming Data Import","id":"confirming-data-import","depth":2}],"frontmatter":{"seo":{"title":"Java SDK Data Import"}},"lastModified":"2026-06-01T09:09:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/tools/cli-and-sdks/java-sdk-import","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}