Skip to content

How to Run A Centipede App

Paul Houle edited this page Dec 29, 2013 · 1 revision

Overview

This article describes how to run a Centipede App. This includes both how to run it directly with the Java command and how to use generated scripts to install your centipede app in Bash or Windows Powershell as well as how to run your centipede App in an IDE.

Fundamentally

A centipede app is packaged as a single JAR and can be run like so:

java [java arguments] -jar project-onejar.jar run appName [app options]

If you run an app like this, you can supply any arguments to the Java command that you wish (to configure the memory heap, for instance) before the -jar argument. The 'appName' is the name of an applcation that is bunded inside the onejar created when you build your project. Any options after the application name will be passed to your application.

We reserve the right to add additional optional arguments before the run command in future versions of Centipede.

This mechanism is orders of magnitudes simpler than the scripts generated by the appassembler maven plugin and can be obviously built into scripts of any kind and allows you to install the generated JAR anywhere in your file system.

Unix Bash Alias

To make things really simple, your Centipede project will build a Bash Shell and Powershell scripts that make your command easy to run.

The unix command is installed at target/path.sh and looks something like

#!/bin/sh
alias centipedeTest="java -jar $HOME/.m2/repository/com/ontology2/centipedeTest/1.0-SNAPSHOT/centipedeTest-1.0-SNAPSHOT-onejar.jar"

The name of the alias is the same as the artifactId of your project. If you type

$ source target\path.sh

you will install centipedeTest in your bash shell, loading the onejar binary out out of your local maven repository. You can add additional commands to your path.sh to configure your environment for working on a particular system. You can either run the source command before you start working on a system or you can add the source command to your .bash_profile or other startup script. Once centipedeTest is loaded, you can type

$ centipedeTest run myApp [arguments]

you cannot directly pass arguments to the java runtime this way, but you can easily write your own alias that contains different runtime arguments.

Windows PowerShell

The path.ps1 script does pretty much the same thing for Windows PowerShell

function centipedeTest {
   java -jar $env:userprofile\.m2\repository\com\\ontology2\centipedeTest\1.0-SNAPSHOT\centipedeTest-1.0-SNAPSHOT-onejar.jar @args
}

The big difference is that you type

> . target\path1.ps1

to install your command into PowerShell. One difficulty you may have is that Windows, out of the box, will not run PowerShell scripts to disable a possible attack vector. If you're serious about using PowerShell on a development machine, I suggest you type

> Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser

which will permanently change your configuration to enable your machine to execute PowerShell scripts.

Running your application in your IDE

It can be convenient to run your application in the IDE, particularly if you want to use the debugger. To do so, you create a run configuration that runs the following class:

com.yourcompany.yourproject.Main

and that has the following command line

run myApp [arguments]