In order to use the library you need to install Java Platform (JDK) version 8 or higher. You can verify this by entering the following command into a terminal:
java -version
# Example output:
# java version "1.8.0_211"
# Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
# Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)
To use the library, the command above must output version 1.8.0 or higher.
There are several IDEs that can be used to create a Maven project which the Zaber library can be added to, or you can use Maven and the command line alone. Below are instructions for IntelliJ IDEA and Maven.
IntelliJ IDEA runs on Windows, macOS and Linux. You can download the free IntelliJ IDEA Community Edition here (you may need to scroll down to see the Community Edition).
In IntelliJ IDEA, follow these steps:
pom.xml.
You may, for example, enter these values: com.someone.example (GroupId), zaber_example (ArtifactId), 1.0 (Version).
You can substitute your own values; this example Group ID is to match the package declaration at the top of
our example program.pom.xml file located in the root folder and add the library into the <dependencies> xml tag: <dependency>
<groupId>com.zaber</groupId>
<artifactId>motion-library</artifactId>
<version>9.0.1</version>
</dependency>
com:zaber:motion-library listed in the External Libraries section of the project tree.App.java in src > main > java > yourProjectName (when yourProjectName is the name you specified).
Edit the file to start writing code. This would be a good time to paste in the example code and run it.If you are not using an IDE for development, download and install Apache Maven (IntelliJ IDEA already includes Maven.) You can verify installation by entering the following command into a terminal:
mvn -v
# Example output:
# Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
# Maven home: C:\Program Files\apache-maven-3.9.6
# Java version: 1.8.0_302, vendor: Temurin, runtime: C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\jre
# Default locale: en_CA, platform encoding: Cp1252
# OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
In the directory where you want to create your project, run:
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.4
It will prompt you to enter some identifying information for your project. Here are some example responses, but choose more suitable names for a production project.
This will leave you with a new subdirectory containing a pom.xml file and an App.java file in a subdirectory.
Edit the pom.xml file. Add this inside the <dependencies> xml tag:
<dependency>
<groupId>com.zaber</groupId>
<artifactId>motion-library</artifactId>
<version>9.0.1</version>
</dependency>
Also find the <plugins> xml tag and add this to the list of plugins already there:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.someone.example.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
Next, edit the App.java file and write your program - you can start with the example code given in the
Basic Example section below.
Make sure you save both files after making the changes.
To compile the program (which will also download the library if needed), run:
mvn clean compile assembly:single
Once the program is successfully compiled, you can run it with:
java -jar target\zaber_example-1.0-jar-with-dependencies.jar
If the mvn command fails to execute, make sure that the JAVA_HOME environment variable is
set to point to your JDK installation.
If you get "Error: Could not find or load main class (something).App" when you try to run your program,
edit the package declaration at the top of your App.java to match what it is expecting or if you're using
the maven-assembly-plugin check that the mainClass XML tag is correct, and then recompile.
If you are already using the library and want to update to the latest version (9.0.1),
change the version of Motion Library plugin to the latest version in the pom.xml located in your project folder:
<dependency>
<groupId>com.zaber</groupId>
<artifactId>motion-library</artifactId>
<version>9.0.1</version>
</dependency>
Then build your project to download the new dependency to your Maven repository.