Using IMu's Java Library
A single jar file, imu-2.0.jar (or higher), is required to develop an IMu-based application. This jar contains all the classes that make up the IMu Java API. Contact Axiell Support for access to the IMu API bundles
As with all jar files, the IMu jar must be included in the Java class path so that the java compiler and java runtime environment can find and use the IMu classes. Tools for Java development such as Eclipse and NetBeans allow you to add a reference to the IMu jar to your project.
All classes in the IMu Java API are included in the one package,
com.kesoftware.imu
. As is usual in Java development you are able to refer
to an IMu class in your code by:
- Using the fully qualified name:
com.kesoftware.imu.Session session = new com.kesoftware.imu.Session();
- Importing the required class explicitly:
import com.kesoftware.imu.Session; Session session = new Session();
- Importing all the classes from the package implicitly:
import com.kesoftware.imu.*; Session session = new Session();
Test Program
Compiling and running this very simple IMu program is a good test of whether the development environment has been set up properly for using IMu:
import com.kesoftware.imu.*;class Hello { static void main(String[] args) { System.out.format("IMu version %s%n", IMu.VERSION); System.exit(0); } }
The IMu library includes a class called IMu
. This class includes the static
String
member VERSION
which contains the version of this IMu release.
Exceptions
Many of the methods in the IMu library objects throw an exception when an error
occurs. For this reason, code that uses IMu library objects should be
surrounded with a try
/catch
block.
The following code is a basic template for writing Java programs that use the IMu library:
import com.kesoftware.imu.*;try { // Create and use IMu objects // ⋯ } catch (Exception e) { // Handle or report error // ⋯ }
Most IMu exceptions throw an IMuException
object. IMuException
is a
subclass of the standard Java Exception
. In many cases your code can
simply catch the standard Exception
(as in this template). If more
information is required about the exact IMuException
thrown, see
Exceptions.
Note: Many of the examples that follow assume that code fragments have been surrounded with code structured in this way.