5

So i try to migrate my project to Java 9 but the process seems not so easy as i thought it would be. I kept getting some errors about invisible packages that i could fix with the following argument in my pom:

<compilerArgs>
     <arg>--add-modules</arg>
     <arg>java.se.ee</arg>
</compilerArgs>

But i still get the following error:

cannot find symbol
[ERROR]   symbol:   class Priority
[ERROR]   location: package javax.annotation

any help would be appreciated

Naman
  • 27,789
  • 26
  • 218
  • 353
  • 1
    Did you read [Java 9: how to get access to javax.annotation.Resource at run time](https://stackoverflow.com/questions/46502001/java-9-how-to-get-access-to-javax-annotation-resource-at-run-time)? If yes, please explain what else did you tried and how is this not a duplicate. – Naman Oct 30 '17 at 08:47
  • 1
    javax.annotation.Priority is not in Java SE or the JDK. If you have javax.annotation-api-1.3.1.jar (maven coordinates: javax/annotation/javax.annotation-api/1.3.1) on your class path then it should work? – Alan Bateman Oct 30 '17 at 09:15
  • 2
    Possible duplicate of [Java 9: how to get access to javax.annotation.Resource at run time](https://stackoverflow.com/questions/46502001/java-9-how-to-get-access-to-javax-annotation-resource-at-run-time) – Naman Oct 30 '17 at 10:01

1 Answers1

7

I'm not sure where javax.annotation.Priority comes from, but a solution analog to getting JSR 305 running on Java 9 should fix your problem: Instead of adding the (deprecated) Java EE module java.xml.ws.annotation (which you do indirectly by adding java.se.ee), you should instead add the javax.annotation package from an external artifact, namely javax.annotation:javax.annotation-api.

If you modularize your code, that solution no longer works and you have to start patching modules. Or, even better, move away from solutions that require non-JDK classes that pretend to come from java or javax packages because that will always cause problems.

Nicolai Parlog
  • 47,972
  • 24
  • 125
  • 255