9

Local Java Version is :

java version "11.0.7" 2020-04-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS, mixed mode)

but my project having java version of :

<java.version>1.8</java.version>

During the build I am getting an error :

Exit code: 1 - javadoc: error - The code being documented uses modules but the packages defined in https://docs.oracle.com/javase/8/docs/api/ are in the unnamed module.

How to solve without changing java version of pom to Java 11 or downgrading to Java 8?

Naman
  • 27,789
  • 26
  • 218
  • 353
Remo
  • 135
  • 2
  • 11

3 Answers3

20

I believe you might just have faced a relevant JDK issue - JDK-8212233 and also related to JDK-8217177

To solve that, one of the recommendations would be to upgrade the JDK, since the fix doesn't look to me as backported to JDK-11 while going through the comments. But yeah, your current version could just be the one impacted.

Ensure, updating the configuration of the Javadoc plugin to

<configuration>
  <source>8</source>
</configuration>
Naman
  • 27,789
  • 26
  • 218
  • 353
2

This error message came up for me when employing the maven-javadoc-plugin. I had cut-and-pasted xml for this plugin that specified version 2.9.1. When I revised this to the latest version (3.4.0 as of this moment), the error went away.

Are you using this plugin? If not, I wonder if you can troubleshoot to identify if there is a specific plugin causing the problem and if that plugin needs updating.

Phil Freihofner
  • 7,645
  • 1
  • 20
  • 41
-1

First check java 8 is installed in the system or not. If not then install it.

Run the application with making default java to 1.8 by using the command:

export JAVA_HOME=`/usr/..path_to_java8../java_home -v 1.8` 

which will help you to switch different versions of java. And that will solve your issue.

Ashish Karn
  • 1,127
  • 1
  • 9
  • 20
  • 3
    The question contains "How to solve without changing java version of pom to Java 11 or downgrading to Java 8?" as you've read. – AbVog Sep 12 '20 at 23:04