CodeSonar Plug-in for Eclipse: Setting Up
Before installing the CodeSonar plug-in for Eclipse, ensure that
all of the following are installed. For detailed instructions, see
Prerequisite Details.
- CodeSonar
- Eclipse, version 4.19 (2021-03) through 4.29 (2023-09),
official/supported releases only.
- A Java version compatible with your Eclipse installation.
- If you want to analyze C or C++ projects: the CDT plug-in for
Eclipse.
- If you want to analyze Java projects: the JDT plug-in for
Eclipse.
Ensure that your installed JRE version is compatible with JDT
plug-in requirements.
- [Windows only] The Microsoft Edge WebView2 runtime.
- [Windows only] If Eclipse is installed in a system folder (such
as Program Files), you will need administrative privileges to
install the plug-in.
Note
In this section (and throughout
this manual), $CSONAR indicates the
CodeSonar
installation directory.
- If you have defined environment variable CSONAR to the
location of the CodeSonar installation
directory, you can use $CSONAR directly in
your command lines. On Windows systems, use
%CSONAR% in
place of $CSONAR.
- If you don't want to use environment variables,
replace $CSONAR with the
path to your CodeSonar
installation directory before using the command
lines.
Follow these instructions to ensure all prerequisites for
installing the CodeSonar plug-in for Eclipse have been satisfied.
- If CodeSonar is not already installed, install it now.
-
If Eclipse is not
already installed, install it now:
- Download the "Eclipse Standard" package for your
local operating system from eclipse.org Downloads.
- Extract the package on your machine.
- Follow any additional instructions provided in the package
INSTALL and README files.
- Start Eclipse.
-
Check to see if the CDT
plug-in for Eclipse is installed.
- In Eclipse, select Help
> About Eclipse.
An About Eclipse dialog will
open.
- Click the Installation
Details button in the About
Eclipse dialog.
An Eclipse Installation
Details dialog will open.
- Check: do "C/C++ Development Tools" and
"C/C++ Development Tools SDK" appear in the
Installed Software tab of the
Eclipse Installation Details
dialog, with version number 8.0, 8.1, or 8.2?
-
Install the CDT
plug-in (if it is already installed, or if you do not
want to analyze any C or C++ projects, go on to check to see if the JDT plug-in for Eclipse is
installed).
- Determine the URL for the CDT plug-in that matches your
Eclipse version by consulting the CDT
Downloads page.
- Select Help >
Install New Software.
An Install dialog will
open.
- In the Install dialog,
click the Add button (in the
upper left corner).
An Add Repository dialog will
open.
- In the Location field of
the Add Repository dialog,
enter the CDT plug-in URL that you determined in step 5a.
- Click OK.
The Install dialog will now
show two options:
- CDT Main Features.
- CDT Optional Features.
- Select both options.
- Click Next and work
through the remainder of the installation process.
When you are prompted with the option to restart Eclipse, click
Yes.
-
Check to see if the JDT
plug-in for Eclipse is installed.
- In Eclipse, select Help
> About Eclipse.
An About Eclipse dialog will
open.
- Click the Installation
Details button in the About
Eclipse dialog.
An Eclipse Installation
Details dialog will open.
- Change to the Plug-ins
tab.
- Check: does "Eclipse Java Development Tools"
appear on the list of installed plug-ins?
-
Install the JDT
plug-in (if it is already installed, or if you do not
want to analyze any Java projects, go on to check your Java installation).
- Determine the download URL that matches your Eclipse
version.
- For Eclipse Kepler, the URL is:
http://download.eclipse.org/releases/kepler
- For other Eclipse versions:
http://download.eclipse.org/releases/<versionname>
- Select Help >
Install New Software.
An Install dialog will
open.
- In the Install dialog,
click the Add button (in the
upper left corner).
An Add Respository dialog will
open.
- In the Location field of
the Add Repository dialog,
enter the download URL that you determined in step 7a.
- Click OK.
The Install dialog will now
show a list of options.
- Click the arrow next to Programming Languages to show further
options.
- Select Eclipse Java Development
Tools.
- Click Next and work
through the remainder of the installation process.
When you are prompted with the option to restart Eclipse, click
Yes.
-
Check your Java
installation. Run the following command line:
java -version
- If the command line output indicates that you have a
suitable version of Java installed (1.6, 1.7, or 1.8), go on to
Installing the CodeSonar
Plug-in.
- If the output indicates that you have another Java version,
or that Java is not installed at all, go on to Install Java.
-
Install Java
(if a suitable version is already installed, go on to Installing the CodeSonar Plug-in).
- Go on to Install the CodeSonar
Plug-in.
There are two ways to install the CodeSonar plug-in:
These instructions use the codesonar
eclipse-install approach.
- [Windows only] if you have installed
Eclipse in a system folder (such as Program Files), make sure you
have administrative privileges. If necessary, consult with your
local system administrator.
- If Eclipse is running, shut it down.
- Make sure that %CSONAR%\codesonar\bin
is in your PATH.
- Otherwise, the codesonar
eclipse-install command you construct in the next step
will have to specify the path to the codesonar executable.
- Run
codesonar eclipse-install
path/to/EclipseDir
where path/to/EclipseDir
is the Eclipse installation directory. If the directory path
includes spaces, enclose it in double quotes "".
- Check to make sure that path/to/EclipseDir/dropins/com.codesonar.eclipse.jar
now exists.
- Start Eclipse.
The top menu bar will now include a CodeSonar menu.
- Go on to Configure the CodeSonar
Plug-in.
Make sure the CodeSonar plug-in is configured correctly: it needs
the CodeSonar installation path in order to perform the CodeSonar
build/analysis.
- From the top menu bar, select CodeSonar > Preferences.
Eclipse will display the Preferences dialog, with the CodeSonar preferences
selected.
- Check: does the Installation
Path field contain the full path to the CodeSonar installation directory?
- YES: no further configuration actions are needed.
- NO: add the path now:
- Enter the full path to the CodeSonar installation directory in
the Installation Path
field: either
- type or paste the path directly in the field,
or
- click Browse, then
use the Browse For Folder dialog to navigate to your
CodeSonar installation
folder and click OK.
- Click Apply.
- Click OK.
To uninstall the CodeSonar plug-in for Eclipse, do the
following.
- Remove file path/to/EclipseDir/dropins/com.codesonar.eclipse.jar,
where path/to/EclipseDir
is the Eclipse installation directory.
- Restart Eclipse.
Once you have upgraded CodeSonar, upgrade your plug-in
installation:
- Uninstall the old version of the
plug-in.
- Install the updated plug-in.
- Configure the plug-in.
Now that the CodeSonar plug-in is installed and configured, you
can:
The following sections provide detailed information about
installing and using the CodeSonar plug-in for Eclipse.