languagetool-org/languagetool · error

No Java rules found - start this script from the languagetoo

Error message

No Java rules found - start this script from the languagetool-standalone directory

What it means

RuleOverview.run counts Java rules while emitting an HTML overview and throws a RuntimeException if overallJavaCount is zero, indicating the script was run from a directory where Java rule classes could not be discovered. The message tells the user the required working directory.

Source

Thrown at languagetool-dev/src/main/java/org/languagetool/dev/RuleOverview.java:167

      // activity:
      int commits = activity.getActivityFor(lang, 365/2);
      int width = (int) Math.max(commits * 0.25, 1);
      String images = "";
      if (width > 50) {
        images += "<img title='" + commits + " commits in the last 6 months' src='images/bar-end.png' width='22' height='10'/>";
        width = 50;
      } else if (width == 1 && commits > 0) {
        width = 3;
      }
      images += "<img title='" + commits + " commits in the last 6 months' src='images/bar.png' width='" + width + "' height='10'/>";
      System.out.print("<td valign=\"top\" align=\"right\"><span style='display:none'>" + commits + "</span>" + images + "</td>");

      System.out.println("</tr>");    
    }
      
    if (overallJavaCount == 0) {
      throw new RuntimeException("No Java rules found - start this script from the languagetool-standalone directory");
    }

    System.out.println("</tbody>");
    System.out.println("</table>");
  }

  private int countRulesForLanguage(Language lang) throws IOException {
    List<String> ruleFileNames = lang.getRuleFileNames();
    int count = 0;
    for (String ruleFileName : ruleFileNames) {
      final URL url = this.getClass().getResource(ruleFileName);
      if (url != null) {
        String xmlRules = StringTools.readStream(Tools.getStream(ruleFileName), "utf-8");
        xmlRules = xmlRules.replaceAll("(?s)<!--.*?-->", "");
        xmlRules = xmlRules.replaceAll("(?s)<rules.*?>", "");
        count += countXmlRules(xmlRules);
        count += countXmlRuleGroupRules(xmlRules);
      }

View on GitHub (pinned to 2e990059ce)

Solutions

  1. Run the script from the languagetool-standalone directory as the message instructs
  2. If using an IDE/Maven, set the working directory to languagetool-standalone
  3. Verify the standalone jar/module with Java rules is on the classpath

Example fix

// before
cd languagetool-dev && mvn exec:java -Dexec.mainClass=org.languagetool.dev.RuleOverview
// after
cd languagetool-standalone && mvn exec:java -Dexec.mainClass=org.languagetool.dev.RuleOverview
Defensive patterns

Strategy: validation

Validate before calling

if (!new File("languagetool-standalone").exists() || !Paths.get(System.getProperty("user.dir")).getFileName().toString().equals("languagetool-standalone")) {
  throw new IllegalStateException("Run from languagetool-standalone");
}

Try / catch

try { new RuleOverview().run(lang); } catch (RuntimeException e) { if (e.getMessage().contains("No Java rules found")) { System.err.println("cd languagetool-standalone and retry"); } }

Prevention

When it happens

Trigger: Running the RuleOverview script from a directory other than languagetool-standalone, so classpath scanning finds no Java rule classes.

Common situations: Executing the dev script from the repo root, from languagetool-dev, or via an IDE with the wrong working directory configured.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of languagetool-org/languagetool@2e990059ce (2026-09-06). Data as JSON: /api/errors/3515ed651e502367. Report an issue: GitHub.