Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

Getting started with kwcheck for Java

Getting started with kwcheck for Java

kwcheck is a desktop analysis tool for C/C++ and Java developers using IDEs and text editors that aren't supported by Klocwork in the form of an IDE plug-in. You can also try the GUI tool Klocwork Desktop.

Set up a local project

Set up a local project and connect it to a server project with kwcheck create.

kwcheck create --url http://server2:8080/my_project

Perform this step only the first time.

Capture your build settings

Capture build settings with kwant .

The following example applies to projects built with Ant 1.7.x or later. If your project is build with Ant 1.6.x, see Manual integration -- editing the Ant build file. If your project contains .jsp files, see Build specifications for projects that contain .jsp files.

To create a build specification with kwant:

  1. Run ant clean.
  2. Navigate to the directory that contains the build.xml file. (Skip this step if you specify the file name with the -f option of ant).
  3. Run kwant:
    kwant —-output /home/klocwork/freemind.out
    

If you're a Maven user, you can use kwmaven to capture your build settings. The following example applies to projects built with Maven 1.5 or later.

To create a build specification with kwmaven:

  1. Run mvn clean.
  2. Navigate to the directory that contains the pom.xml file. (Skip this step if you specify the file name with the -f option).
  3. Run kwmaven install:
    kwmaven —-output /home/klocwork/freemind.out install
    

Keep your build specification up to date: Whenever you add files, remove files or change compilation flags, create a new build specification with kwant or kwmaven and import it into your project with kwcheck import. See Creating a Java build specification for more information about build specifications.

Import the build specification

Import the build specification with kwcheck import.

kwcheck import my_project.out

Run the analysis

  1. Analyze your code with kwcheck run.
    kwcheck run
    
  2. Display detected issues with kwcheck list.
    kwcheck list -F detailed
    
    Note: When you run the analysis, any new issues detected are local issues. To see system issues, you can specify the --system option.
    Traceback identifies statements in the source code that contribute to detected issues.

See Java checker reference for documentation on detected issues.

Fix defects and ignore the rest

  1. Fix the real defects.
  2. Re-run the analysis.
    kwcheck run
    
  3. Display detected issues.
    kwcheck list -F detailed
    
    When an issue disappears from the list, it's fixed.
  4. Ignore issues you don't care about with kwcheck set-status.
    kwcheck set-status 23-25,30,32 --status Ignore -c "this is 3rd party software"
    
    Your changes are now visible to other developers, and in Klocwork Static Code Analysis. Your desktop project is also updated with any changes made by other developers. This happens even before another integration build analysis.