I have the url which needs credentials and I am navigating to that through selenium + Java https://username:password.example.com/
However it still shows the login window
This provides multiple approaches for handling Authentication pop-ups.
I would suggest to use WebDriver’s switchTo.alert() syntax to access them and then use methods such as sendKeys(), accept() or dismiss()
switchTo.alert()
sendKeys()
accept()
dismiss()