The full build isn't compatible with Java 11 yet, so you need both 8 and 11
configured in a toolchains.xml config. Then you need to use Java 8 as the
default JVM (or at least the contents of JAVA_HOME), and the build will
switch to higher version compilers for the modules that require it.
Ideally, the build would be updated to simplify this, but it's a fairly
difficult problem as it's still a relatively new area in Maven with
multiple alternatives to how to support it.

On Tue, 8 Dec 2020 at 08:13, Volkan Yazıcı <volkan.yaz...@gmail.com> wrote:

> Would you mind changing the default JDK you start *mvnw* to version 8 and
> retrying via *./mvnw clean package -DskipTests*, please? (Here *clean*
> goal is necessary for removing the class files compiled earlier with the
> wrong JDK.)
> [Sorry for the short answer, struggling with my day-job in the meantime.]
>
> On Tue, Dec 8, 2020 at 3:02 PM Joseph Tsai <jtsa0...@gmail.com> wrote:
>
>> Hi Volkan,
>>
>> I just installed both JDK8 and 11 and tried to do mvn clean install. The
>> same error persists, and I think it's looking at my default Java
>> installation?
>> Running "sudo update-alternatives --config java" shows the following:
>> [image: image.png]
>> Currently it is defaulted to Java15, and everytime I change the default
>> Java the wrong version circled in blue changes.
>> [image: image.png]
>> I also looked up what version 53 is, it is apparently Java9?
>>
>> My questions are:
>>
>>    - Am I supposed to update the default Java to Java11 or 8? If not, is
>>    simply putting in more toolchain entries under toolchains.xml is enough?
>>    - How is Java9 related to the error message, if at all?
>>    - Honestly I am not sure what I'm supposed to do with the maven.yml
>>    example you linked...
>>
>> I have also attached a new copy of my updated toolchains.xml. A bit of
>> information on my environment, I'm using Windows and do development through
>> WSL2.0.
>>
>> Thanks once again,
>> Joseph
>>
>> On Tue, 8 Dec 2020 at 22:44, Volkan Yazıcı <volkan.yaz...@gmail.com>
>> wrote:
>>
>>> Hello Joseph,
>>>
>>> You need to have both JDK 8 and 11 installed and configured in your
>>> toolchains.xml file. For reference, you can check how we do it in GitHub
>>> Actions workflow: maven.yml
>>> <
>>> https://github.com/apache/logging-log4j2/blob/master/.github/workflows/maven.yml
>>> >
>>> and maven-toolchains.xml
>>> <
>>> https://github.com/apache/logging-log4j2/blob/master/.github/workflows/maven-toolchains.xml
>>> >.
>>> Once this is done, *./mvnw package -DskipTests* should succeed. Let us
>>> know
>>> if you encounter any further troubles.
>>>
>>> Kind regards.
>>>
>>> On Tue, Dec 8, 2020 at 12:22 PM Joseph Tsai <jtsa0...@gmail.com> wrote:
>>>
>>> > Hi everyone,
>>> >
>>> > I forked and cloned the project from GitHub
>>> > <https://github.com/apache/logging-log4j2>. And spent the past couple
>>> of
>>> > hours trying to build from source with mvn install.
>>> >
>>> > It is failing with errors saying "class file has wrong version 55.0,
>>> > should be 53.0" for "bad class file:
>>> > /modules/java.base/java/util/EnumSet.class", which I think it means I
>>> > probably need to find a Java 9 to install and build the project with?
>>> But
>>> > since Java 9 was discontinued, I haven't been able to find an Oracle
>>> nor an
>>> > OpenJDK version to install.
>>> >
>>> > I have attached an output txt file for maven install and my current
>>> maven
>>> > toolchain.xml if it helps clarifying what I might have been doing
>>> wrong.
>>> >
>>> > Thanks,
>>> > Joseph
>>> >
>>>
>>

Reply via email to