Adabas Client for Java and Eclipse

#### Search Results

Search

# Adabas Client for Java and Eclipse

This tutorial provides an introduction to working with Adabas Client for Java and Eclipse.

- Adding the Adabas Client for Java Example Programs in Eclipse

- Running the Example Program AdabasAuthSearchExample

Note
The Installation directory of Adabas Client for Java contains a set of JavaDocs for Adabas Client for Java, as well as example Java programs.

## Adding the Adabas Client for Java Example Programs in Eclipse

This tutorial explains how to add the example programs from Adabas Client for Java into Eclipse. In the final step you will execute one of the example programs in Eclipse.

To add example programs from Adabas Client for Java in Eclipse

This tutorial assumes that a current version of Eclipse (currently Luna 4.4.1) is installed and running on your local machine. It also assumes that you have a demo Adabas database running on your local machine.

1. From the Eclipse File menu, choose New > Java Project.

   The New Java Project dialog is displayed.

2. Enter the name of the new project (for example AdabasClientForJavaExamples) in the in the field Project name. Click on the button Finish to create the new project.

3. Select the new project in the Eclipse Package Explorer, then choose Properties from the Eclipse File menu.

   Or:
   Right-click on the new project in the Eclipse Package Explorer, then choose Properties from the context menu.

   The Properties for ProjectName dialog is displayed.

4. Select Java Build Path on the left side of the dialog, then select the Libraries tab on the right side of the dialog.

   The JARs and class folders on the build path are listed.

5. Click on the button Add External JARs... and then select the acj jar file from install directory\AdabasClientForJava\lib.

   Note
   The install directory (by default, this is "SoftwareAG") can be changed during the installation.

   The JAR Selection dialog is displayed.

6. In the JAR Selection dialog, select the acj-<version>, log4j-<version>, slf4j-api-<version>, slf4j-log4j-<version> jar file from install directory\AdabasClientForJava\lib, then click on the button Open.

7. Click on the button OK in the Properties dialog to add the jar file to the Referenced Libraries.

   The next step is to add the Javadoc location.

8. Expand the object acj jar on the right side of the Properties dialog and select Javadoc location, then click on the Edit... button.

   The Javadoc for 'acj jar' dialog is displayed.

9. Select the radio button Javadoc in archive, then click on the Browse... button next to the field Archive path.

   The Javadoc Archive Selection dialog is displayed.

10. In the Javadoc Archive Selection dialog, select the acj javadoc jar file from install directory\AdabasClientForJava\lib, then click on the button Open to add the Javadoc location.

    Notes:

    1. Add the value "docs" in the field Path within Archive.
    2. Click on the button Validate for verification.
    3. Click on the button OK in the dialogs Javadoc For 'acj jar' and Build Path to return to the Eclipse main screen.

    The next step is to create a new Java package in the folder src.

11. Select the new project (in this case AdabasClientForJavaExamples) in the Eclipse Package Explorer, then click on the New Java Package icon in the tool bar.

    Or:
    Right-click on the new project, and then choose New>Package from the context menu.

    The New Java Package dialog is displayed.

12. In the New Java Package dialog, enter the string com.softwareag.adabas.query.examples.classic in the field Name. Click on the button Finish to add the new package to the project.

    Repeat this step, this time entering the string com.softwareag.adabas.query.examples.mapping in the field Name.

    The next step is to import source files to the new packages.

13. Select the new package com.softwareag.adabas.query.examples.classic in the Eclipse Package Explorer, then choose Import... from the Eclipse File menu.

    Or:
    Right-click on the new package, and then choose Import... from the context menu.

    The Import dialog is displayed.

14. In the Import dialog, select General -> File System and click on the button Next. In the subsequent Import dialog, click on the Browse... button next to the field From directory and navigate to the directory that contains the source files (in this case \install directory\AdabasClientForJava\examples\classic). Click on the Select All button to select all of the source files to be imported. Click on the Finish button to import the source files to the new package.

    Repeat this step for the new package com.softwareag.adabas.query.examples.mapping, this time importing the source files from \install directory\AdabasClientForJava\examples\mapping).

    The next step is to verify that Javadoc is working correctly.

15. Double-click on the file AdabasSearch.java in the Eclipse Package Explorer to open it for editing. Move your cursor over an occurrence of the string AdabasTarget in the source code - the corresponding Javadoc text should be displayed in a popup window. Click on the icon Open Attached Javadoc in Browser to display the text in your web browser.

    The final step is to execute one of the example programs.

16. Select the example program AdabasSearch.java in the Eclipse Package Explorer, then click on the run icon in the toolbar to run it; you will be prompted to enter the DBID of your demo database in the Eclipse Console window, then press Enter to run the program.

    The results of running the program are displayed in the console of the Eclipse main screen, which will look something like this:

## Running the Example Program AdabasAuthSearchExample

There are two ways in which the example program AdabasAuthSearchExample can be run from Eclipse:

- Use Run As Java Application - in this case, it is not possible to disable echoing of the password.

- Use Show In Terminal - in this case, it is possible to hide the password during input.

Examples of each case (including output) are shown below; in each case, you must first select the example program AdabasAuthSearchExample.java in the Eclipse Package Explorer.

#### Example: Run As Java Application

Click on Run As -> Java Application from the toolbar, as shown below:

The output in the IDE console window will look something like this:

#### Example: Show In Terminal

Click on Show In -> Terminal from the toolbar, as shown below:

The output in the IDE classic Terminal window will look something like this:

### On this page

- Adding the Adabas Client for Java Example Programs in Eclipse
- Running the Example Program AdabasAuthSearchExample