Getting Started in Java

How to get started your own app in Java

Google tutorial for Java developers

  1. Set up JDK and Maven

  2. Create a new java project with maven:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
  1. Add artifact dependency to your pom.xml file:
  <dependencies>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>2.5.0</version>
    </dependency>
    ...
  <dependencies>
  1. Add protoc jar maven plugin execution to your pom.xml file:
  <build>
    <plugins>
      <plugin>
        <groupId>com.github.os72</groupId>
        <artifactId>protoc-jar-maven-plugin</artifactId>
        <version>2.5.0.4</version> <!-- for protobuf 2.5.0 -->
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <includeDirectories>
                <include>src/main/protobuf</include>
              </includeDirectories>
              <inputDirectories>
                <include>src/main/protobuf</include>
              </inputDirectories>
            </configuration>
          </execution>
        </executions>
      </plugin>
      ...
    </plugins>  
    </plugins>
  </build>
  1. Download the latest version of Trading API .proto sources from our online guide: open-api-proto-lib.zip

  2. Extract them to the src/main/protobuf folder of your project

  3. Execute "mvn generate-sources" to generate Java sources (.java files). These files will be generated in target/generated-sources folder of your project

NOTE:

  • You can access the proto classes using "com.xtrader.protocol.proto.openapi" package.

Please find working sample project here: connect-java-samples

Just open and build it using you favourite Java IDE.

Enjoy!