Why do you need the Db URL? And what has JAVA to do with it?
The setting you show in the image is the configuration used for local deployment. When you want to use your own local postgres, oracl, SQL etc database for local testing.
In the Mendix cloud this is already configured. If you run on your own (cloud) servers, then you need to configure that in your runtime settings and the Db URL is in that scenario know by you. No need to do anything with Java.
There is a GetApplicationURL java action in the CommunityCommons module in the appstore.