How can I have Java programmatically set the IP address and hostname, rather than have to set it in my PC's host file?
I am writing a java program to test if a web application that resides behind a load-balancer is responding or not. Say the application is: app.company.com, and it resides on two different servers, with ip addresses: 1.1.1.1 and 2.2.2.2. Currently my test application updates the PC's hosts file, setting either "1.1.1.1 app.company.com" or "2.2.2.2 app.company.com" and then uses Apache HttpClient v4.5.10 to call the web application via: app.company.com And this works, with the change in the hosts file directing the call to the desired server.
But I would prefer to do this programmatically rather than updating the hosts file. Thoughts?