Is there any way to replace the javax.* to jakarta.* packages inside the dependencies of my module without recompiling them? At compile/deploytime? Spring boot 3 / Java 17
Asked
Active
Viewed 1,220 times
1
-
I think you need dependencies compiled for JDK 9+ and 11+. If you own those dependencies, you will have to recompile them. See also: [Java Magazine ~ Transition from Java EE to Jakarta EE](https://blogs.oracle.com/javamagazine/post/transition-from-java-ee-to-jakarta-ee) – Mr. Polywhirl May 30 '23 at 18:20
-
2I think you'd have to do some kind of byte code re-write of all the classes of your dependencies. I think it is doable but weird and complicated. If your dependencies are open source projects it is probably easier do download the source, replace the imports and build the new versions. – Lii May 30 '23 at 18:30
-
I have to keep dependency code unmodified, cause there are other consumers, with java ee8 – ZedZed May 31 '23 at 15:24
-
This makes no sense. You can simply modify your dependencies and release them with a new version without impacting the other consumers. – Abhijit Sarkar May 31 '23 at 15:31
-
1Look up "Eclipse Transformer". – BalusC May 31 '23 at 15:38
-
@AbhijitSarkar, then I have to support two versions of dependency in parallel. I'm not saying, that there is no other way. The point of this question is to find out, is there an utilities/approaches for this case and compare all pros/cons to obvious solutions – ZedZed May 31 '23 at 15:39
-
I found the dupe. See link above. – BalusC May 31 '23 at 15:45
-
@BalusC, yep, thanks, I hoped some alternatives are appeared for the last year – ZedZed May 31 '23 at 15:47
-
1Eclipse Transformer apparently does its job so good that no one found urge to reinvent it. Another alternative is to simply swap out CXF for [Metro](https://github.com/eclipse-ee4j/metro-jax-ws) (you tagged `cxf` so I gather you're actually ultimately after using an already Jakartified JAX-WS implementation), yet another alternative is to use stock Jakarta EE instead of Spring ;) – BalusC May 31 '23 at 15:51
1 Answers
2
Your dependencies are already built. You cannot alter their package names. (Unless you took extreme measures, not recommended, as commented.)
You will need to use only those dependencies that have been updated to the new jakarta.*
naming, and updated to run in modern Java.
Or stick with the original version of Jakarta EE 8, which uses the old javax.*
packages. Same as Java EE 8. Implementations are still supported, so no pressing need to migrate to the current Jakarta. You’ll migrate eventually, but you can wait for the dependencies to migrate.

Basil Bourque
- 303,325
- 100
- 852
- 1,154
-
Yep, extreme measures is what I meant. I'm searching for a byte code modifier (as one of solution), cause those dependencies are being used by other modules with EE8 (javax). – ZedZed May 31 '23 at 15:19
-
@ZedZed Then edit your Question to make clear your willingness to use extreme measures. Because that approach would be highly unusual. – Basil Bourque May 31 '23 at 15:22
-