Skip to content

Best SAST Tools for Java in 2026

Suphi Cankurt

Written by Suphi Cankurt

Key Takeaways
  • SonarQube and SpotBugs are the default free starting point for Java - SonarQube for breadth and quality gates, SpotBugs with FindSecBugs for bytecode-level security checks. Running both takes minutes to set up in Maven or Gradle.
  • CodeQL gives Java projects the deepest inter-procedural taint analysis available for free (on public repos) - it models Spring, Struts, and Jakarta EE entry points and tracks user input across the codebase.
  • Checkmarx, Fortify, and Coverity are the three enterprise Java SAST platforms most common in regulated industries. Checkmarx stands out for CxQL custom queries. Fortify for legacy and COBOL+Java hybrid codebases. Coverity for defect-density metrics.
  • Semgrep and Snyk Code bring developer-first Java scanning into the IDE with taint analysis. Snyk Code traces data flow across files and methods. Semgrep is strong for custom rules against proprietary frameworks.
  • For a production Java service, the most effective free stack is: SonarQube Community plus SpotBugs in CI, CodeQL via GitHub Actions on the main branch, and Semgrep for custom rules. Add Snyk Code or Checkmarx when you need commercial taint analysis and audit trails.

Java remains the backbone of enterprise software - banking systems, government services, large internal platforms - and its mature ecosystem means Java SAST has deeper tooling than almost any other language. This guide compares 8 SAST tools with strong Java support: SonarQube, SpotBugs, CodeQL, Semgrep, Snyk Code, Checkmarx, Fortify, and Coverity.

Looking for the full SAST landscape? This guide focuses on Java-specific coverage. For all 50+ SAST tools including enterprise platforms, see the complete SAST tools list or the open source SAST tools guide.

Why Java SAST is different

Java’s static type system and mature compiler make it one of the easier languages to analyze statically. Tools can resolve types, trace method calls, and build accurate call graphs. That means Java SAST detection quality is generally higher than for Python or JavaScript at the same tool tier.

The trade-off is framework complexity. A modern Java service sits on Spring Boot, Struts, or Jakarta EE, with dependency injection, annotation-driven routing, and reflection-heavy serialization. A SAST tool that does not model these frameworks will miss the entry points where user input actually enters the application.

The major Java-specific vulnerability patterns SAST tools target include unsafe deserialization (the class of bugs behind Log4Shell and older Apache Commons issues), JNDI injection via lookup strings, SQL injection through JPA and raw JDBC, XXE in XML parsers, Spring Expression Language (SpEL) injection, Struts action injection, LDAP injection, path traversal through servlet request parameters, and hardcoded secrets in application.properties or application.yml.

Java also has a longer tail of legacy code than most languages. SAST tools that run at the bytecode level (SpotBugs, Coverity) handle code where source may not be available or where the source was generated by a build tool. That matters in large enterprises running decades-old code alongside new services.

Key Insight

For Java SAST, framework modeling is the moat. Any scanner can grep for Statement.executeQuery. Only the scanners that know a Spring @RequestParam is a tainted source, a Jakarta EE @Inject field carries request state, and Apache Commons ObjectInputStream is a dangerous sink will find the actual bugs in real Spring Boot code.


Top SAST tools for Java

1. SonarQube

SonarQube is the most widely deployed Java static analysis platform. Its Java rule set covers OWASP Top 10 categories, Spring-specific patterns, servlet vulnerabilities, and a large body of code quality rules that overlap with security concerns (null dereferences, resource leaks, thread safety).

What SonarQube does well: Integration is native with Maven and Gradle via the sonar-scanner plugin. Quality gates block pull requests that introduce new issues. The Community Edition covers pattern-based Java security well and pairs with code coverage and duplication metrics in one dashboard. SonarQube’s Java analyzer understands common frameworks out of the box.

Where SonarQube falls short: Inter-procedural taint analysis - following user input from an HTTP request parameter across method calls to a SQL sink - requires Developer Edition or above. Community Edition misses complex injection patterns that span classes.

Best fit: Java teams that want one platform covering security plus code quality with a low setup cost, and that are willing to pay for Developer Edition when taint coverage becomes a hard requirement.

SonarQube Server dashboard for a Java project showing a failed Quality Gate with 10 Security Hotspots, 0 Vulnerabilities, and a Security Review C rating — the pull-request blocking gate described in the prose

2. SpotBugs

SpotBugs is the actively maintained successor to FindBugs. It analyzes Java bytecode directly, which means it can inspect compiled class files and libraries where source code is not available. The FindSecBugs plugin extends it with 130+ security checks.

What SpotBugs does well: Bytecode analysis catches issues that source-level tools miss, including calls into third-party libraries and generated code. FindSecBugs provides deep Java security coverage: servlet and JSP injection, cryptography misuse, deserialization, JNDI, LDAP, XXE, and more. It is open source (LGPL) and integrates with Maven, Gradle, Ant, and most IDEs.

Where SpotBugs falls short: The UI and integrations feel older than modern SAST platforms. False positives are higher than with commercial tools because SpotBugs errs toward reporting rather than filtering. Results need tuning to be actionable.

Best fit: Any Java project that compiles to class files. SpotBugs with FindSecBugs is the strongest free bytecode-level security scanner for Java and pairs well with SonarQube.

The SpotBugs GUI inspecting a FindBugs project - left tree groups findings by priority and category, right pane shows Util.java:108 with a Medium bad-practice Stream not closed finding, confirming the bytecode-level inspection described in the prose

3. CodeQL

CodeQL models Java code as a queryable database and ships a comprehensive library of queries for Java taint tracking. Its Java support includes Spring, Struts, Jakarta EE, JAX-RS, and common ORM frameworks, with data flow tracking that crosses method and class boundaries.

What CodeQL does well: Deep Java inter-procedural data flow analysis that actually understands framework semantics. CodeQL knows that a Spring @RequestParam annotation creates a tainted source, that a Jakarta EE injected @Inject field may carry request state, and that Apache Commons ObjectInputStream is a dangerous sink. Queries for Log4Shell-style JNDI patterns are shipped and maintained by GitHub’s security lab.

Where CodeQL falls short: Analysis time is longer than pattern-based tools - 10 to 30 minutes on medium Java projects is common. Writing custom queries in QL has a learning curve. CodeQL is free for public repositories via GitHub Actions but requires GitHub Advanced Security for private repos.

Best fit: Java services with complex taint flows where detection accuracy is critical. For open-source Java projects, CodeQL via Actions is the best free deep scanner available.

CodeQL for VS Code running a Java query.ql (import java; from MethodAccess ma where ma.getMethod equals empty string) and returning 15 results on the Apache ActiveMQ project in 10 seconds — concrete evidence of CodeQL's Java queryable-database model described in the prose
Note: If your SAST evaluation includes Log4Shell coverage, explicitly ask each vendor whether they ship dedicated JNDI injection and unsafe-deserialization queries for Java. CodeQL, Checkmarx, Fortify, and Coverity all do. SonarQube Community and Semgrep CE cover the simpler patterns but miss the framework-aware variants.

4. Semgrep

Semgrep supports Java through its structural pattern-matching engine. The Semgrep Registry includes Java rulesets for OWASP Top 10, Spring security patterns, Struts, JAX-RS, and common deserialization sinks. Custom rules in YAML make it straightforward to encode rules for proprietary frameworks.

What Semgrep does well: Custom rule authoring is the standout feature. A Java platform team that owns an internal framework can write Semgrep rules against it in minutes. The community registry covers common Java patterns and includes rules equivalent to many FindSecBugs checks. Semgrep’s taint engine tracks tainted values within a file.

Where Semgrep falls short: Deep cross-file taint analysis requires Semgrep Code (the paid platform tier). The community engine is strong for single-file analysis but does not track taint across the codebase the way CodeQL or Snyk Code do.

Best fit: Java platform teams with proprietary frameworks that need custom detection, and multi-language organizations that want a single scanner across Java, Python, and JavaScript.

Semgrep CE terminal output running semgrep --config=auto scanning 847 files and reporting a python.flask.security.injection.tainted-sql-query SQL injection ERROR and a python.lang.security.audit.dangerous-yaml-load ERROR - the structural pattern-matching rule IDs that make custom Java rules straightforward to author

5. Snyk Code

Snyk Code provides commercial Java SAST with real-time IDE feedback and inter-procedural taint analysis. Its engine understands Spring Boot, Struts, JAX-RS, and common ORM patterns, and traces user input across methods and files to dangerous sinks.

What Snyk Code does well: Taint analysis that crosses method and file boundaries with high accuracy. The IDE experience in IntelliJ and VS Code surfaces issues inline as developers type, with fix guidance that includes code suggestions. Results include the data flow path from source to sink, which speeds up triage.

Where Snyk Code falls short: The free tier is limited to the IDE. CI/CD integration with full taint analysis requires a paid plan. Snyk Code is a SaaS tool - source code is sent to Snyk’s cloud for analysis, which matters for some regulated or air-gapped environments.

Best fit: Java development teams that want commercial-quality taint analysis with a developer-first IDE workflow, where cloud-based analysis is acceptable.

Snyk Code IntelliJ plugin showing 8 Code Security findings including SQL Injection at line 32 of HomeController.java, CWE-89, with a 6-step data flow path from HomeController through SearchRepository - the cross-file Java taint analysis described in the prose

6. Checkmarx

Checkmarx is one of the longest-standing enterprise SAST platforms with strong Java coverage. Its Checkmarx SAST engine supports Spring, Struts, Jakarta EE, and JAX-RS, and its CxQL query language lets security teams write custom queries against the abstract syntax tree.

What Checkmarx does well: CxQL custom queries are the primary advantage for security teams that need tool-level control. Checkmarx’s Java engine includes a comprehensive default ruleset covering injection, deserialization, cryptography, and framework-specific issues. Incremental scanning reduces pipeline time after the initial full scan.

Where Checkmarx falls short: Setup and tuning take time. False positive rates on initial scans are typical of enterprise platforms and require an AppSec team to triage and suppress. Pricing is not publicly listed and requires a sales conversation.

Best fit: Regulated industries (finance, government, healthcare) with dedicated AppSec teams that need customizable query authoring, audit trails, and on-premise deployment options.

Checkmarx SAST Results Viewer showing a Stored XSS vulnerability with attack vector getSession → getAttribute → authNMsg → addObject traced across mav.java, and a Best Fix Location marker on line 57 - the inter-procedural data flow analysis described in the prose

7. Fortify Static Code Analyzer

Fortify Static Code Analyzer (now under OpenText) is the enterprise Java SAST most common in large banks, government contractors, and organizations with legacy codebases. It supports Java alongside COBOL, ABAP, PL/SQL, and other enterprise languages in one engine.

What Fortify does well: Coverage of legacy and mixed-language codebases is Fortify’s signature strength. A bank with Java services calling into COBOL batch jobs can scan the full stack in one tool. Fortify’s Java engine covers Spring, Struts, Jakarta EE, and a long list of enterprise frameworks. Audit workbench features support large AppSec team workflows.

Where Fortify falls short: The user experience reflects its enterprise origins and can feel heavy compared to modern developer-first tools. False positives on default configuration are typical of the enterprise category. Pricing requires direct vendor engagement.

Best fit: Large enterprises with legacy Java codebases and mixed-language requirements, particularly those with compliance or contractual obligations that mandate a named enterprise SAST vendor.

Fortify Audit Workbench reviewing a Cross-Site Scripting Persistent finding in init_pdf_upload.java line 94 with the Analysis Evidence panel tracing the taint flow from VDHPDFForm.java assignments to the PrintWriter.println sink - Fortify's enterprise Java audit workflow

8. Coverity

Coverity (Synopsys, now part of Black Duck) is a defect-density focused SAST platform with strong Java analysis. Its engine is known for low false positive rates on C and C++ and carries a similar philosophy into its Java checks.

What Coverity does well: Accuracy and defect-density reporting. Coverity positions itself as the tool with the lowest false positive rate among enterprise SAST platforms, which makes its results higher signal per finding at the cost of some recall. Its Java coverage includes deserialization, injection, resource leaks, and concurrency issues.

Where Coverity falls short: Framework coverage for modern Java (Spring Boot, microservices patterns) has historically lagged dedicated Java-first tools like Checkmarx. Setup is enterprise-grade and requires a named deployment effort. Pricing is not public.

Best fit: Java shops that already use Coverity for C or C++ analysis and want a single vendor across their stack, or teams that prioritize signal-to-noise ratio over maximum recall.


Comparison table

ToolTypeJava DepthTaint AnalysisLicenseBest For
SonarQubeSAST + qualityStrong patternsPaid tiers onlyOpen source / CommercialQuality + security in one platform
SpotBugsSAST (bytecode)Deep (with FindSecBugs)LimitedOpen source (LGPL)Bytecode-level Java checks, free
CodeQLSAST (deep analysis)Very deepCross-codebaseFree (public) / CommercialDeep Spring/Struts/Jakarta EE taint
SemgrepSAST (multi-language)Strong patternsSingle-file (CE)Open source / CommercialCustom rules, multi-language
Snyk CodeSAST (commercial)Deep + frameworksCross-fileCommercial (free IDE tier)Developer-first taint analysis
CheckmarxSAST (enterprise)Deep + CxQLCross-codebaseCommercialCustom query authoring, compliance
FortifySAST (enterprise)Deep + legacyCross-codebaseCommercialLegacy and mixed-language Java
CoveritySAST (enterprise)Deep, low FPCross-codebaseCommercialLow false positive rate

How to choose for your use case

Small team or open-source project: Run SonarQube Community plus SpotBugs with FindSecBugs in CI. Add CodeQL via GitHub Actions on the main branch (free for public repos). That covers breadth, bytecode-level security, and deep taint for zero cost.

Growing Java team with Spring Boot services: Same free stack plus Semgrep for custom rules against any internal framework. This gives you 80% of the coverage of a commercial tool with no license spend. Graduate to Snyk Code or SonarQube Developer when cross-file taint becomes a consistent gap.

Regulated enterprise (finance, healthcare, government): Checkmarx or Fortify for the audit trail, on-premise deployment, and compliance features. Checkmarx wins when custom query authoring matters. Fortify wins when you have legacy code or mixed-language requirements. See the enterprise SAST tools guide for the broader landscape.

Legacy Java alongside COBOL, ABAP, or older stacks: Fortify is the most common choice because it covers the full enterprise language list in one engine.

Teams already invested in GitHub Actions: CodeQL integrates natively and is free for public repos. For private repos on GitHub Advanced Security, CodeQL gives you deep Java taint analysis without a separate SAST vendor.

Pro tip: Before you pay for a commercial Java SAST, try the free stack on a representative repository for a two-week pilot: SonarQube Community via the sonar-scanner Maven plugin, SpotBugs + FindSecBugs via the spotbugs-maven-plugin, and CodeQL via the github/codeql-action in a GitHub Action on main. Count the real findings you would have missed without commercial taint. That number is the commercial tool’s upper-bound ROI.

Monorepo with Java plus Python or JavaScript: Semgrep or Snyk Code keeps the scanner count down. Semgrep for custom-rule-heavy teams. Snyk Code for developer-first taint analysis across languages.


Open source vs commercial

Side-by-side comparison visual: left panel Free Open-Source Stack at $0/year (SonarQube Community, SpotBugs with FindSecBugs, CodeQL via Actions, Semgrep CE); right panel Enterprise Commercial requiring a license (Checkmarx CxSAST, Fortify SCA, Coverity, Snyk Code) - summarizing the two paths discussed in this section

The free Java SAST stack - SonarQube Community, SpotBugs with FindSecBugs, CodeQL (public repos), Semgrep CE - is stronger than the free stack for almost any other language. For many Java projects, the combination covers pattern-based issues, bytecode-level security, and cross-codebase taint analysis without a commercial license.

The gap versus commercial tools is primarily in three areas. First, inter-procedural taint analysis on private repositories at CI speed - CodeQL’s quality is free only for public repos, so private-repo teams either pay for GitHub Advanced Security or switch to Snyk Code, Checkmarx, or Fortify. Second, custom query authoring for proprietary frameworks - Checkmarx CxQL and Semgrep (commercial tier) are the main options. Third, audit trails, RBAC, and on-premise deployment required by regulated industries.

Coverity and Fortify stand out when the Java codebase intersects with other languages - C, C++, COBOL, ABAP - where single-vendor coverage matters more than best-of-breed Java analysis.

For a more detailed look at the free and open-source options, see the open source SAST tools guide. For buying considerations around commercial tools, see SAST vs SCA: which do you need first. For sibling language guides, see SAST tools for Python and SAST tools for JavaScript.


FAQ

This guide is part of the resource hub.

Frequently Asked Questions

What is the best free SAST tool for Java?
SonarQube Community Edition and SpotBugs are the two strongest free options for Java. SonarQube ships a comprehensive Java ruleset covering OWASP Top 10 categories and integrates with Maven, Gradle, and most CI platforms. SpotBugs (the maintained successor to FindBugs) adds bytecode-level analysis with the FindSecBugs plugin, catching issues that source-level tools miss. Running both together costs nothing and covers complementary ground.
Does SonarQube Community Edition include taint analysis for Java?
No. SonarQube Community Edition catches pattern-based Java security issues but does not perform inter-procedural taint analysis. Taint tracking that follows user input across method and class boundaries requires SonarQube Developer Edition or higher. For free taint analysis on Java, CodeQL via GitHub Actions is the strongest alternative - it is free for public repositories and covers Spring, Struts, and Jakarta EE frameworks in depth.
Is SpotBugs still maintained?
Yes. SpotBugs is the actively maintained successor to FindBugs, which was last updated in 2015. SpotBugs ships regular releases and has an active community. For security-focused analysis, the FindSecBugs plugin adds more than 130 Java security checks covering injection, deserialization, cryptography, and servlet vulnerabilities. SpotBugs works at the bytecode level, so it analyzes compiled .class files and catches issues that source-only scanners may miss.
Which SAST tool catches Log4Shell-style deserialization bugs?
CodeQL, Checkmarx, Fortify, and Coverity all ship dedicated queries for JNDI injection and unsafe deserialization patterns of the kind exploited by Log4Shell. CodeQL’s Java taint model is particularly thorough for this class of bug because it models framework entry points (HTTP handlers, message listeners) and traces tainted values through logging calls and reflection APIs. SpotBugs with FindSecBugs catches the simpler patterns. Any Java scanner you choose in 2026 should explicitly list JNDI and deserialization coverage.
Do I need a commercial Java SAST if I already use SonarQube?
It depends on whether you need inter-procedural taint analysis. SonarQube Community catches pattern-based Java issues well and pairs naturally with SpotBugs and CodeQL to cover deeper data flow for free. Commercial Java SAST tools like Checkmarx, Fortify, and Coverity add enterprise features: audit trails, RBAC, on-premise deployment, and custom query languages (CxQL for Checkmarx). If your Java code handles regulated data or sits behind contractual audit requirements, the commercial path often comes down to compliance needs rather than pure detection capability.
Suphi Cankurt

Years in application security. Reviews and compares 209 AppSec tools across 11 categories to help teams pick the right solution. More about me →