Packaging the JVM COBOL Application from the Command Line

The build.xml file provides instructions to build the product, the build target, and to package it, the create_jar target.

  1. If a build.xml file does not already exist in the root of the addressBookJVM project then create it:
    1. Click the addressBookFX project.
    2. Click File > New > Other

      This opens the New dialog box.

    3. Click XML > XML File, and then click Next.

      This opens the New XML File dialog box.

    4. In the File name field, type build.xml.
    5. Click Finish.
  2. If a build.xml file does not already exist in the root of the addressBookWrapper project then create it.

    Use the above steps, a through e.

  3. If a build.xml file does not already exist in the root of the addressBookFX project then create it.

    Use the above steps, a through e.

Prepare the environment to be compiled:

  1. Click Start > Micro Focus Visual COBOL > Visual COBOL Command Prompt (32-bit) or Visual COBOL Command Prompt (64-bit).
    This opens the command prompt.
    Note: This path is for Windows 10. The path may vary between versions of Windows. See To start Enterprise Developer command prompt for more information.
  2. Set the JAVA_HOME environment variable to point at Java JDK 1.8.0, at the command prompt, enter:
    set JAVA_HOME=java_installation_folder
  3. Add the path to the Java JDK installation to the PATH environment variable, at the command prompt, enter:
    set PATH=%JAVA_HOME%\bin;%PATH%
  4. Set the ANT_HOME environment variable to points to the Ant installation folder, at the command prompt, enter:
    set ANT_HOME=ant_installation_folder
  5. Add the path to the Ant installation to the PATH environment variable, at the command prompt, enter:
    set PATH=%ANT_HOME%\bin;%PATH%
  6. Set the mfant.jar to be used. This is required to compile JVM COBOL projects.

    Ensure that mfant.jar is in your CLASSPATH variable, if not then enter:

    set CLASSPATH=%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar;%CLASSPATH%

    Alternatively, add the following parameter when calling ant:

    -lib "%ProgramFiles(x86)%\Micro Focus\Visual COBOL\bin\mfant.jar"
  7. You need to compile the three projects in the order addressBookJVM, addressBookWrapper, and addressBookFX. In the command prompt, change your folder location to match the workspace path. To compile the addressBookJVM project, at the command prompt, enter:
    ant -f addressBookJVM\build.xml

    This builds the addressBookJVM project. You will see BUILD SUCCESSFUL displayed in the command prompt. It creates the addressbookjvm.jar in the dist folder.

  8. To compile the addressBookWrapper project, at the command prompt, enter:
    ant -f addressBookWrapper\build.xml

    This creates the addressbookwrapper.jar in the dist folder.

  9. To compile the addressBookFX project, at the command prompt, enter:
    ant -f addressBookFX\build.xml

    Creates the dist folder and the addressbookfx.jar is added.

  10. Add the three jar files that you have created to the CLASSPATH. At the command prompt, enter:
    set CLASSPATH=%CD%\addressBookFX\dist\addressbookfx.jar;%CD%\addressBookWrapper\dist\addressbookwrapper.jar;%CD%\addressBookJVM\dist\addressbookjvm.jar;%CLASSPATH%
  11. You can now run the application from the command prompt, enter:
    java com.addressBookFX.MainClass

    The Address Book COBOL Demo application is displayed. It should look similar to this:


    Address Book COBOL Demo

    You can now use the Add, Edit, and Delete commands to modify records.