How To: Use the sample Rest API client

EnterMedia provides a simple Rest API for external systems to interact with it. This API also allows developers to create their own User Interface (UI). To demonstrate how to use EnterMedia's REST API, we've developed a sample terminal client in Java. This way developers can easily start a new EnterMedia client project.

Downloading

The sample java client is distributed as a zip file. You can get this file directly from our website. The file includes:

  • Source code
  • Eclipse project and classpath files, so you can import it directly into your workspace
  • Apache Ant build file, ot make it easier to build the client
  • All required libraries, including the client itself as a jar file
  • A readme file, in HTML, with usage instructions and examples
  • Javadoc files

Building

The bundle comes with an Ant build file so you can just run it to build the client. If you are not using ant, you can just use plain javac to compile the classes in the src folder, passing in all the jar files in the lib directory into the classpath.

Running

The most basic way of running the sample client is by just invoking the Java virtual machine, passing along the right arguments. That is, telling it that the classpath contains all the jar files in the lib directory and that the main method is in the com.entermedia.ui.ConsoleClient class. This should look like:
java -cp lib/commons-codec-1.3.jar:lib/commons-httpclient-3.1.jar:lib/commons-logging-1.1.jar:lib/dom4j-1.6.1.jar:build/compile com.entermedia.ui.ConsoleClient <args>

A better way of running it is using ant:
ant -Dcommandline="<args>" run
this will take care of building the client and setting the right classpath for it.

Finally, an even easier way of running the client in linux is using the included javaclient.sh script:
sh javaclient.sh <args>
this script requires a JAVA_HOME environment variable to be set.

For more information about the arguments for the client please look at the readme.html file inside the docs folder, in the zip file.