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 installable by downloading the latest version (1.2.2) JAR file from the shared drive.
  • Subsequently, JAR file should be copied into your Maven folder.
  • Finally, ensure to provide the appropriate path in your pom.xml file.
  • After completing the aforementioned steps to install all Contrail dependencies, execute the following command:
mvn clean install

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();
        });
    }
}