Java in the form of OpenJDK remains free. The only scenario where you have to pay for it is if you're using it against an Oracle db or something else from Oracle.
https://medium.com/@javachampions/java-is-still-free-c02aef8c9e04
(Note, I don't use Java)