Home > REST/ROA > Restlet with Java SE

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. restlet-jse-2.0.9.zip. 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.data.Protocol;
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
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: