Monday, April 18, 2022

[Fixed] Java lang exceptionininitializererror com sun tools javac code typetags

Oracle Java Certification, Oracle Java Career, Java Skills, Java Jobs, Java Learning, Oracle Java Tools

A quick guide to fix java lang exceptionininitializererror com sun tools javac code typetags with maven.

1. Overview

In this tutorial, We’ll learn how to fix the error “Java lang exceptionininitializererror com sun tools javac code typetags” when working with maven build.

2. Fix 1 – Java lang exceptionininitializererror com sun tools javac code typetags

Fixing this issue is by providing the correct java version.

In the pom.xml file, you might be giving the java version as below.

<maven.compiler.source>1.11</maven.compiler.source>

<maven.compiler.target>1.11</maven.compiler.target>

Below is the complete pom.xml file for reference.

<project xmlns="http://maven.apache.org/POM/4.0.0"

         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>

    <artifactId>Deep</artifactId>

    <version>1.0-SNAPSHOT</version>

    <properties>

        <maven.compiler.source>1.11</maven.compiler.source>

        <maven.compiler.target>1.11</maven.compiler.target>

        <dl4j.version>0.9.1</dl4j.version>

    </properties>

    <dependencies>

        <dependency>

            <groupId>org.nd4j</groupId>

            <artifactId>nd4j-native-platform</artifactId>

            <version>${dl4j.version}</version>

        </dependency>

        <dependency>

            <groupId>org.deeplearning4j</groupId>

            <artifactId>deeplearning4j-core</artifactId>

            <version>${dl4j.version}</version>

        </dependency>

        <dependency>

            <groupId>org.datavec</groupId>

            <artifactId>datavec-api</artifactId>

            <version>${dl4j.version}</version>

        </dependency>

        <dependency>

            <groupId>org.nd4j</groupId>

            <artifactId>nd4j-api</artifactId>

            <version>1.0.0-beta3</version>

        </dependency>

        <dependency>

            <groupId>org.deeplearning4j</groupId>

            <artifactId>deeplearning4j-play_2.11</artifactId>

            <version>0.9.1</version>

        </dependency>

    </dependencies>

</project>

This error may be appearing from jdk version after 1.9. and version has to be as 10 or 11 or 12 or 14 or 17.

And java versions should not start with “1.xx” after 1.9 versions. So, you provide the java version as 1.XX then you will see mostly “Java lang exceptionininitializererror” error.

To fix this error you need to change the java version as follows.

<maven.compiler.source>11</maven.compiler.source>

<maven.compiler.target>11</maven.compiler.target>

3. Fix 2 – Java lang exceptionininitializererror com sun tools javac code typetags

If the above fix does not work that means any one of the dependencies are needed to have the higher java versions.

You can find all transitive dependencies using “mvn dependency:tree” command 

For example, if you are using deeplearning4j-core.jar file then you may need to get the latest lombak jar file to fix the issue.

Add the below jar as a dependency in pom.xml file.

<dependency>

  <groupId>org.projectlombok</groupId>

  <artifactId>lombok</artifactId>

  <version>1.18.2</version>

  <scope>provided</scope>

</dependency>

4. Fix 3 – Java lang exceptionininitializererror com sun tools javac code typetags

If the above two solutions did not work then you need to change JAVA_HOME to the latest one or you need to change the jdk version in the eclipse.

Source: javacodegeeks.com

Related Posts

0 comments:

Post a Comment