Search code examples
javaeclipsejavadoc

Fail to build Javadoc with java 17 in Eclipse


I've my project in Eclipse and since few weeks that's failed do build my javadoc, because I've a syntax problem with arrow in it. The console return I need to use an upper version of Java 14 to to it. The problem, it's my java is java 17, so I don't understand where I must look... to fix that. Indeed, I've no problem to build my library!!! just for the javadoc.

error: switch rules are not supported in -source 8
          case '[' ->
                   ^
  (use -source 14 or higher to enable switch rules)

my setting : enter image description here


Solution

  • Eclipse is doing what you asked it to do.

    javac17 can still be configured to compile java 8 code. Just like, say, 'Word 2024' can still open files made with 'word 2016'.

    And.. it is. That's what the -source 8 is about: You're running javadoc -source 8 .....

    Click on 'next' twice. You will see the option 'JRE source compatibility'. Set that to at least 15; it is currently on 8, so eclipse is dutifully telling javac (invoked by javadoc to parse the doc comments and signature out) to parse it as if its java 8 compatible source, and expression-switches aren't compatible with that.