Core Java

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

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.

How to create maven project?

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.

5. Conclusion

In this article, we have seen the fixes to maven error – “Java lang exceptionininitializererror com sun tools javac code typetags” and its solutions.

How to fix java lang UnsupportedClassVersion?

Published on Java Code Geeks with permission by Venkatesh Nukala, partner at our JCG program. See the original article here: [Fixed] Java lang exceptionininitializererror com sun tools javac code typetags

Opinions expressed by Java Code Geeks contributors are their own.

Venkatesh Nukala

Venkatesh Nukala is a Software Engineer working for Online Payments Industry Leading company. In my free time, I would love to spend time with family and write articles on technical blogs. More on JavaProgramTo.com
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Ethan
Ethan
2 years ago

Thanks a ton! was trying to figure it out for long. Step 4 worked for me as I installed visual studio 2022 and that updated the java jdk version to 11.0 and that created the exception issue. Post removing the same from the environmental variables issue got fixed.

Back to top button