Since javax.* packages have been replaced with Jakarta.* packages in the latest release of spring 6 and hibernate I am facing a bit challenge to replace all import statements related to javax.* with Jakarta.* in all files(1000s of java files) at once. I am using the latest eclipse IDE and have ubuntu OS. Right now I am replacing it manually by opening one java file at a time. Is there a way to do this at once for all files?
Asked
Active
Viewed 1,397 times
-1
-
2have you checked this? https://stackoverflow.com/questions/6800799/replace-string-in-all-files-in-eclipse – Pavel Jan 05 '23 at 07:36
-
If only there were a "Replace all" kind of functionality in the IDE.... – Shark Jan 05 '23 at 11:49
-
You can do the SED approach. However, it also requires to carefully review and check libraries used in your app. All libs need to support jakarta namespace ;-) – rzo1 Jan 19 '23 at 19:20
2 Answers
0
You could use the Eclipse Transformer tool available from the Apache TomEE project here:
https://tomee.apache.org/latest/docs/jakartaee-9/eclipse-transformer.html
"The Eclipse Transformer provides translation from
javax
tojakarta
on various artifacts, including Java source source, compiled Java classes, along with jar, war and ear files."
The README page contains instructions for building the transformer tool and documentation on how to use it.
Another alternative would be use Eclipse's search / replace across your entire codebase; see Replace String in all files in Eclipse. However that is potentially risky; e.g. because of the possibility of making mistakes in the patterns that you use.

Stephen C
- 698,415
- 94
- 811
- 1,216