Archive for the ‘REST/ROA’ Category

Restlet with Java SE

There are three ways to use Restlet within Eclipse IDE. The first one is to create a Java project and use the Restlet JARs as external libraries. Download the latest stable Java SE edition here and extract the archive, i.e. Add the library in the lib folder in your project properties.

The second way is to install Restlet JARs as Eclipse/OSGi bundles. All Restlet JARs including dependencies are valid OSGi bundles, so this is very convenient if you work in an Eclipse plug-in environment, such as an Eclipse RCP application. You then just need to create a plug-in project. Have a look at the FAQs here for more informations.

My prefered way is to use Maven. Install Maven and create an eclipse project. Then create a new java class MyServerResource and insert the following code:

import org.restlet.Server;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

public class MyServerResource extends ServerResource {

	public static void main(String[] args) throws Exception {
		// Create the HTTP server and listen on port 8182
		new Server(Protocol.HTTP, 8182, MyServerResource.class).start();

	public String toString() {
		return "hello, world";

Then add the Restlet repository to your pom.xml:

<name>Public online Restlet repository</name>

And the dependency:


Then run your project and open http://localhost:8182 in your a Web browser.

Categories: REST/ROA