Swim - Get Started

Swim developer logo developer.

Get Started


The instructions below will install any desired SWIM libraries to your machine.

Java


Following these instructions will make SWIM-Server and the Java SWIM-Client available for use by your project.

Prerequisites

  1. Install JDK 8. Ensure that your JAVA_HOME environment variable is pointed to the Java 8 installation location. Ensure that your PATH includes $JAVA_HOME.
  2. Install Gradle. Ensure that your PATH includes the Gradle bin directory.

Verification

  1. Clone the swimit/swim-academy repository onto your system.
  2. Point a shell to the basics/services directory.
  3. Run gradle build from this shell.
A successful build sufficiently indicates that your system is ready to use SWIM-Server.

Your Own Application

The aforementioned basics/services directory is a good template, down to the src subdirectory structure, for any SWIM application. Thus, the easiest way to build your own project is to simply tweak this project. To build your own SWIM backend from scratch, we recommend the following steps:

  1. Copy the build.gradle file to your otherwise empty project folder, tweaking only the class names as necessary.
  2. Import this file into your IDE of choice, or manually create the Gradle project layout in a new src subdirectory of your project folder
  3. Point a shell to the project folder.
  4. Run gradle build from this shell.

At this point, there are two ways to run your application.

  • Execute gradle run from this shell; this runs your application in a Gradle VM.
  • After running gradle build, unpackage one of the two compressed files in the newly-created build/distributions directory. The bin directory inside the unpackaged folder contains executable scripts that will run the application without the Gradle VM.

JavaScript


Following these instructions will make the JavaScript SWIM-Client available for use by your project. There are ultimately two dependencies that you need in your environment, recon-js and swim-client-js.

Node

In a shell pointed to your project directory, run

  • npm install recon-js
  • npm install swim-client-js

Raw JavaScript

The libraries themselves are available for direct use, e.g. inside an HTML <script> tag. Both scripts are available in a single download.

SWIM-UI


The same swim-app.min.js from before also enables SWIM-UI. Simply add

<script src=http://cdn.swim.ai/javascript/swim-app.min.js><script>

to your HTML file.