Scanning a Java application

Learn how to scan a Java™ application for impact analysis.

Prerequisite: Before you scan the Java source files, make sure that you prepare the files as described in Preparing the source files to be scanned.
Note: Wazi Analyze UI does not support the display of impact analysis graphs for a Java application. You can access the results from Wazi Analyze APIs or use Application Discovery UI to view the results.
Complete the following steps to set up and scan Java source files.
  1. If you have not yet done so, start the container and launch the container terminal.
  2. Create a project for Java source by running the following command.
    wa-create.sh <project-name> java
    Note:
    • Replace the <project-name> with the name of your project.
      • The valid characters that can be used in the project name are A-Z, a-z, 0-9 and _.
    For example, you can run the following command to create a javaApp project for Java.
    wa-create.sh javaApp java

    The javaApp directory is created under /home/wazi/data.

  3. Transfer or copy source files to be scanned into the /home/wazi/data/<project-name>/source directory. Also copy any extra jar files (aside from standard java) that your application requires into this same directory.
  4. Scan the source files by running the following command.
    wa-scan.sh <project-name> <dat-file-path>

    <project-name> is an optional parameter to specify the name of the project that you are scanning. If the parameter is not specified, the default project is scanned.

    <dat-file-path> is an optional parameter to specify the absolute path and the name of the configuration file (.dat). If the parameter is not specified, the default path is used to find the configuration file. The default path is /home/wazi/data/<project-name>/<project-name>.dat.

    For example, to scan Java source files in the javaApp project and use the javaApp.dat file in the /home/wazi/ directory as the configuration file, run the following command:
    wa-scan.sh javaApp /home/wazi/javaApp.dat

    The scan results are in the sub-directories of /home/wazi/data/<project-name>.

    • For a summary of error messages, check the /home/wazi/data/<project-name>/<project-name>.log file.
    • For complete scan results, check the /home/wazi/data/<project-name>/Output/Scan.log file.
  5. View the scan log files. Fix the errors that are reported and scan the source files again. For more information about how to fix common scan errors , see Understanding the scanning messages in the scan log file.
    Note:
    • You can use any text editor to view or edit the file.
    • If you use the VI editor, you can run the following command to open the file.
      vi /home/wazi/data/<project-name>/Output/Scan.log
      You can use the following keys to change the editing mode of VI editor:
      • Press i to go to edit mode.
      • Press Esc + :wq to save and exit.
      • Press Esc + :q! to exit without saving.
  6. When no errors are found in the scan results, start the Wazi Analyze server. For more information, see Starting up and shutting down the server.
  7. Access scan results by using one of the following methods.
    • Use Wazi Analyze APIs. For more information, see Using Wazi Analyze APIs.
    • View the impact analysis graphs from Application Discovery. For more information, see Java Call Graph.
      Note:

      The first time you configure integration between AD and Wazi Analyze, the /home/wazi/data directory is mounted to the directory on the Application Discovery server. The original data in this directory, the project directory and the GenAppC sample project, will no longer be available. You can restore both the project directory and the GenAppC sample project from the /home/wazi/templates/data directory, if needed.

      In the case that you have additional projects that are created or scan results in the default project, you need to back up the entire data directory and autoDB.txt file to be restored later. For more information, see Backing up project data.

      After you complete the configuration, the /home/wazi/data directory on the Wazi Analyze container and the mounted location on Application Discovery server will be synchronized automatically. At this point, if you have the project data that you backed up earlier, you can restore it to the data directory.