0

I am trying to upgrade my java application from Java 7 to Java 11 version. My local is setup with jdk11 and Java_Home is updated as well. Running the app in Intellij 2023.1 IDE which is the latest version.

When running the local application which is pointing to Jdk11 facing Error: 'Exception in thread "main" java.lang.NoClassDefFoundError: javax/annotation/PreDestroy'. Changes made to my local are the jdk previously was pointing to java 8, now it is pointing to java 11.

I have read previous posts on the same error and everyone suggested for a downgrade of the jdk from 11 to 8. But in my case I have to upgrade the application to Java 11 and the the project is on Ant build.

Any help is appreciated. Please let me know if any additional information is required.

I have tried upgrading the libraries and still the same issue is persist.

Nani
  • 29
  • 4
  • 1
    The `javax.annotation` package is no longer included in Java, you need to add the appropriate dependency. – Mark Rotteveel Jun 20 '23 at 12:40
  • @MarkRotteveel Mine is a ant project. Any suggestion on the replacement for javax.annotation package? – Nani Jun 20 '23 at 13:05
  • 1
    Try to try to download the JAR from [Maven central](https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api) and add the [dependency to ant project](https://stackoverflow.com/questions/26650590/how-to-add-dependency-to-ant-project) – Miguel Monteiro Jun 20 '23 at 13:28
  • 2
    Also, make sure you're using an Ant version which is compatible with Java 11. – Mark Rotteveel Jun 20 '23 at 13:33
  • 1
    @MarkRotteveel Added latest jar and upgraded ant version. Solution worked. Appreciate your help! – Nani Jun 21 '23 at 13:44
  • @MiguelMonteiro Added latest jar and upgraded ant version. Solution worked. Appreciate your help! – Nani Jun 21 '23 at 13:44

0 Answers0