Creating Your First Hello COBOL World Application

Now that we've covered the basic features of the Eclipse IDE, it is time for you to create your first simple Hello COBOL World application:

Create a project

  1. Start Visual COBOL.

    By default, when you start Eclipse, it displays the Eclipse Launcher dialog box prompting you to specify a path for the Eclipse workspace. Specify a path and click Launch.

    If this is the first time you start Eclipse, you now see the Eclipse Welcome page. See The Eclipse Welcome Page in this Introduction.

    Click Open COBOL Perspective as this perspective is the most suitable one for COBOL development.

  2. Select File > New > COBOL Project.
  3. Specify a name for your project such as HelloCOBOLWorld, ensure Micro Focus template [32 bit] is selected, and click Finish.

    By default, the project will be created in the workspace that you selected when you started the Eclipse session.

Add a source file

You need to create a program in your project to hold the COBOL source code:

  1. Select your project in the COBOL Explorer view and click File > New > COBOL Program.

    The New COBOL Program wizard is displayed.

  2. In the New file name field type helloworld.cbl.
  3. Click Finish.

    This adds a template COBOL program to your project and opens it in the editor.

  4. Copy and paste the following COBOL code into the editor, overwriting the existing text:
           program-id. helloworld as "helloworld".
           environment division.
           configuration section.
           data division.
           working-storage section.
           procedure division.
               display 'Hello COBOL World!'.
           end program helloworld.
  5. Click File > Save.

    By default, Eclipse builds your project automatically. If you haven't configured Eclipse to do this, you can build a project at any time by clicking Project > Build Project.

    The progress of the project build is displayed in the Console view.

    When your project has been built, a folder called New_Configuration.bin is created in your project. Expand the folder in the COBOL Explorer view to see the executable and some .obj (Windows) or .o (UNIX) files.

You can now run the application.

Run Hello COBOL world

Applications you create in Eclipse need a launch configuration to execute. You are going to create a run configuration for the Hello COBOL world application as follows:

  1. Select your project in the COBOL Explorer view and from the main menu click Run > Run Configurations.
  2. Create a new launch configuration. You can do this in two ways:
    • Double-click the COBOL Application tree item.
    • Click COBOL Application tree item, and then click the New launch configuration icon.

    A default COBOL Launch Configuration is created in the wizard showing HelloCOBOLWorld as the project to run and New_Configuration.bin/HelloCOBOLWorld.exe (Windows) or New_Configuration.bin/HelloCOBOLWorld (UNIX) as the main program to run.

  3. Click Run.

    This opens a console window with Hello COBOL World! printed in it.

  4. Press any key to close the console.

Preserve this project because you are going to use it again for a different demonstration included in this Introduction.

What Next?

Continue with the next section, Advanced Details, which includes information about configuring the IDE and your projects, and on editing, building, running and debugging applications in Eclipse.