Chapter 2. Creating and Deploying a PC Application

Table of Contents
Creating an Application
Deploying an Application
[Note]Note
In this context the term PC application is used to denote any application that runs on a machine with a Java Virtual Machine (JVM) installed. For example: a desktop PC with Linux, Mac OS X, Unix or Windows, a server, a tablet PC, a mobile device or any other device that supports Java.

A PC application can contain hundreds or thousands of source code files hierarchically organized in directories.

Creating an Application

To create, compile and run an application do the following:

  • Open a terminal window and go to any directory in which you want to create the project.

  • Create a new project named hello by entering the following command:

    ppl create_project id=hello

    PPL creates a sub-directory named hello.

    Moreover, a number of subdirectories and files are created under hello. To get more information about them please have a look at the README file in the project's root directory.

    An important file is se_hello_starter.ppl which has been created under hello/work/ppl/source_code/hello/. This file contains the entry code that will be executed when the application starts.

  • Open file hello/work/ppl/source_code/hello/se_hello_starter.ppl with your preferred text editor, look at the comments, and insert the following instruction in the script of command start:

    OS.out.write_line ( "Hello world" )

    The whole source code should look as follows (comments removed):

    service hello_starter
    
       command start
          in command_line_arguments nullable indexed_list<nullable string>
    
          script
             OS.out.write_line ( "Hello world" )
          .
       .
    
    .
  • Save the file.

  • Compile and build your project by executing the compile_and_build system file which is located in your project's root directory (i.e. compile_and_build.sh on Unix and compile_and_build.bat on Windows).

    Alternatively you can also type the following two commands:

    ppl compile_project
    ppl build_project

    or (using the shortcuts of compile_project and build_project):

    ppl cp
    ppl bp
  • Now run your application by executing the run system file in your project's root directory (i.e. run.sh on Linux systems and run.bat on Windows systems). Or type ppl run_project, or simply ppl rp.

    Your screen displays:

    Hello world

Deploying an Application

To package your application into a single file for deployment on other computers:

  • Execute the package system file in your projects root directory (i.e. package.sh on Linux systems and package.bat on Windows systems). Or type ppl package_project or ppl pp

    This command creates a single compressed file in your project's distribute subdirectory. The file contains everything needed to execute your application on another PC that has Java installed. There are two version of this file:

    1. a file with extension .tar.gz: use this file to deploy on a Linux/Mac/Unix machine

    2. a file with extension .zip: use this file to deploy on a Windows machine

To install your application on another PC, follow the steps below:

  • Ensure that the correct Java version is installed on the PC. If it isn't, you must first install or upgrade Java.

  • Copy the compressed file created in the previous step to the PC (use the .tar.gz file on a Linux/Mac/Unix machine or the .zip file on a Windows machine). You can use any directory, but you should of course consider the standards and permissions of the PC's operating system.

  • Unzip the file.

  • Run the application by executing the system command file located in the application's root directory (e.g. hello.sh on Unix and hello.bat on Windows).