Skip to content

Java SDK

Requirements

  • Java 1.8+ Our developer tools are built on Java and utilize the modern Maven packaging system. The current version is compatible with Java 1.8. Additionally, it builds and runs with Java 17. Java can be installed from Java's main site, while Maven can be installed from maven main site.

Installation

  • The functionality within the VibeIQ platform (Contrail) can be accessed and extended using a Java SDK.
  • The SDK is available as a Maven dependency, which simplifies its integration into your Java project.
  • To use the Contrail SDK in your project, add the following dependency to your pom.xml file
<dependency>
    <groupId>com.vibeiq.contrail-java-sdk</groupId>
    <artifactId>contrail-java-sdk</artifactId>
    <version>2.0.2</version>
</dependency>
  • You can find more details and download options for this dependency on the Maven Central Repository.
  • After completing the aforementioned steps to install all Contrail dependencies, execute the following command:
mvn clean install
  • With the Contrail SDK dependency now included, you can begin extending and accessing the VibeIQ platform's functionality directly within your Java project. Simply import the necessary classes and start implementing your custom logic.

For detailed API documentation refer to the official Contrail SDK Documentation.

App development

In the world of Java, code can be written in a class, run through the java interpreter, or packaged as part of an application. Below are examples on how to authenticate and print your username in each of these paradigms.

To use the Contrail Java SDK as part of your class, you can use the import keyword.

home.java
import com.vibeiq.sdk.core.request.auth.Login;
import java.util.concurrent.CompletableFuture;
import com.vibeiq.sdk.core.request.auth.models.User;
import com.vibeiq.sdk.core.request.auth.models.Organization;

public class Home {
    public static void main(String[] args) {
        // Call main method of Login class
        Login.main(args);
        CompletableFuture<User> userFuture = Login.getCurrentUser();

        userFuture.thenAccept(user -> {
            System.out.println( "Login Success as " + user.getEmail());
            System.out.println("Is member/owner of below orgs");

            for (Organization organization : user.getOrgs()) {
                System.out.println(org.getOrgId() + ": " + org.getOrgSlug());
            }
        })
        .exceptionally(e -> {
            e.printStackTrace();
        });
    }
}