By googling for "alerts selenium" (
http://lmgtfy.com/?q=alerts+selenium ) I found that all of the top three search results provided tangible, useful and correct code examples of how to handle JS alerts using Selenium WebDriver in Java. However, the third link, below, is particularly helpful and informative:
http://www.softwaretestinghelp.com/handle-alerts-popups-selenium-webdriver-selenium-tutorial-16/
After reading and understanding this article and trying to employ a similar technique in your own code, do you have any *specific* questions related to a problem you are having?
In order to find information on your own, and ask better questions when you can't find the information, it is recommended that you perform a small amount of research (e.g. Google) about your problem before you ask a question on a mailing list.
Hope that helps,
Sean