Simple Java Application Project (v4.0)

A simple project to deploy and run a Java application

Project overview.

Here is a summary of what this project will achieve.

This project is designed to deploy a Java application onto a server, and then run it. The server in the project is Linux, but can be Windows or Linux. 

One target environment is configured in the project (for Linux). We can easily clone this project to add a Windows flavour.

Taking the Linux example, the environment demonstrates how the project payload (HelloWorld.jar) is generic, and can be parameterised differently in each of the target environments. 

Parameters can be passed to the jar as command line arguments, Java Options and as environment variables.

When you run the project for each of the environments, view the logs once the deployment is finished, and see how the running jar file echoes out the different command line parameters and environment variables.

What is preconfigured and demonstrated

The project demonstrates the following configurations:
  • Target server for Linux using localhost
  • Use of the Remote agent plugin
  • A jar file, as payload
  • Environment variables per environment
  • Command Line arguments per environment
  • CommandRunner task
  • Cloning an environment

How to use this project.

  1. Download the project to your desktop by clicking on one of the links. The file will be saved as java-deploy.zip
  2. Log into your RapidDeploy instance as mvadmin.
  3. Navigate to Resources-> Projects.
  4. In the top right hand corner click on the Upload Project button.
  5. Select the zip file you downloaded in step 1.
  6. You are guided through a project import wizard. The important thing to check and change (if necessary) here is the path to the project storage directory.
  7. Once the project is imported, there are a couple of things youll need to do.
    • Firstly, navigate to  Resources ->  Projects  and edit the project. Navigate to the  Packages  tab and click the  Create Package   button. A new package is created with a version number. This is the package you'll deploy later, containing all the environment definitions, actions and paylod ( HelloWorld.jar ) to allow the jobs to be run on all defined servers.
    • By default this job will run on the localhost. If you're happy to run it here, skip to point 8. If you don't want it to run here, you'll need to clone the environment and choose a new logical host name. The other parameters can stay the same. Once you've created this environment, an empty server definition with the logical hostname you chose will have been created. You will now need to configure this host. 
    • To do this navigate to   Resources ->  Targets  ->   Servers  . Select the server  with the logical name ( Display Name ) you just created. Change the hostname from localhost to the IP, DNS or resolvable hostname you actually want to connect to. You might also need to change the  Transport  tab to use either SSH or the MidVision remote agent plugin. The default here is to use the agent on the localhost to the RapidDeploy server, which if you followed a standard RapidDeploy install is installed and configured by default.
  8. Now you can run a new job to the environment of your choice. 
    • Navigate to Jobs-> New Job
    • Select the project you created earlier. You will see a tree view of server/environment and application. 
    • Select the one you want to deploy and follow the wizard. 
    • On the Version panel you select the version (package version) you want to deploy. 
    • Since there is only one package, it is preselected. The latest package will always be preselected by default. 
    • Click on the Skip to Finish checkbox and click Next
    • On the final tab click the Start Job button. The deployment is started and you see the tasks executed and job log in real time.

Optional Task: Clone the environment to another Server

Now we've deployed to a linux server, let's clone the environment to run on another server too.

  1. Firstly, navigate to    Resources  ->    Projects   and edit the project. Navigate to the    Environments   tab.
  2. For the one environment listed, in the Action column, select the Clone Logical Environment  button.
  3. On the Name tab, change the Server Display Name to localhost-win  (if you ran the HelloWorld demo project, this will already exist, otherwise type it in). If you don't have a windows server, type the name of another Linux server. Leave the other values the same and click Next.
  4. On the Configure Directory  tab, leave the defaults. as we are creating this environment in the same project. Click Next
  5. Click through the next tab - Here you would configure environment specific Data Dictionary items to make them different for this new environment. There aren't any in this project so the tab is empty. Skip to the Finish tab and click Create This Environment button.
  6. Now you've created the environment, we will configure the localhost-win server. Click on the localhost-win server (or the new logical name you chose) in the environments list. This is a fast path to the server definition.
  7. Check the Hostname . It should be localhost.
  8. Click the Edit  button in the bottom right - change the Hostname to the resolvable hostname, IP adderss or DNS name of your target server.
  9. Click the Save button
  10. Now create a new package on the project, which will include this server definition.
  11. Now you have a package with two environment definitions, and you can now deploy to either one, or both.

Further Reading

The following links will help you gain a deeper understanding of the tasks used in this project:

Download this project!