I have try to run this sample code
package edsAutomation;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Example {
public static void main(String[] args) {
    // declaration and instantiation of objects/variables
    WebDriver driver = new FirefoxDriver();
    String baseUrl = "http://newtours.demoaut.com";
    String expectedTitle = "Welcome: Mercury Tours";
    String actualTitle = "";
    // launch Firefox and direct it to the Base URL
    driver.get(baseUrl);
    // get the actual value of the title
    actualTitle = driver.getTitle();
    /*
     * compare the actual title of the page witht the expected one and print
     * the result as "Passed" or "Failed"
     */
    if (actualTitle.contentEquals(expectedTitle)){
        System.out.println("Test Passed!");
    } else {
        System.out.println("Test Failed");
    }
    //close Firefox
    driver.close();
    // exit the program explicitly
    System.exit(0);
}
}
But when i run my program it show below error:
Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot 
find firefox binary in PATH. Make sure firefox is installed. OS appears to 
be: XP
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', 
java.version: '1.8.0_25'
 
     
    