Skip to content
Kevin Ormbrek edited this page Apr 22, 2014 · 17 revisions

You can incorporate jrobotremoteserver into your project or use it as a standalone jar.

Table of Contents

Programmatic Usage

    public class ServerLauncher {
        public static void main(String[] args) throws Exception {
            RemoteServer.configureLogging();
            RemoteServer server = new RemoteServer();
            server.putLibrary("/", new MyLibrary());
            server.putLibrary("/other", new MyOtherLibrary("42"));
            server.setPort(8270);
            server.start();
        }
    }

Embedded Usage

How to add a servlet to a servlet container varies. Here is an example for Tiny Java Web Server:

    import java.util.Properties;
    import Acme.Serve.Serve;
    
    public class ServerSetup {
    
        private Serve server = null;
        
        public void startServer() throws Exception {
            server = new Serve();
            Properties properties = new Properties();
            properties.put("port", 9999);
            server.arguments = properties;
            RemoteServerServlet servlet = new RemoteServerServlet();
            servlet.putLibrary("/", new MyLibrary());
            server.addServlet("/jrobotremoteserver", servlet);
            server.addDefaultServlets(null);
            server.runInBackground();
        }

Standalone Usage

To download version 3.0 or above, use the releases page. For earlier versions, use the downloads page.

First configure the CLASSPATH to include your libraries and jrobotremoteserver. Then do something like this:

 java org.robotframework.remoteserver.RemoteServer --library org.example.MyLibrary:/ --library org.example.MyOtherLibrary:/other --port 8270

For help on command line options do:

 java org.robotframework.remoteserver.RemoteServer --help

Status Page

Once the remote server has launched, you can see a status page in a web browser. The page displays what libraries are mapped to which paths, and is served regardless of the path in the URL. For example, go to http://localhost:8270/ if the server is running on port 8270.

Stopping the Server

You can stop the server in one of several ways:

  1. Execute keyword Stop Remote Server from Robot Framework (can be disabled)
  2. Raise a keyboard interrupt in the console -- CTRL + C
  3. Call RemoteServer.stop()
  4. Call XML-RPC method stop_remote_server() (disabled if the first option is)

Adding as a Maven Dependency

<dependency>
    <groupId>com.github.ombre42</groupId>
    <artifactId>jrobotremoteserver</artifactId>
    <version>3.0</version>
</dependency>