I am writing test script using Cucumber Java + Maven, I want to get browserType from pom.xml, by using this code:
String browserType = System.getProperty("browser");
but it does not working. Below is my code in common function to launch browser which is specified in pom.xml
package com.cucumber.utils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class commonFunctions {
    static String driverPath="D:\\chromedriver";
    public static WebDriver launchBrowser(){
    WebDriver driver;
//  String browserType = "firefox";
    String browserType = System.getProperty("browser");
    String appURL = "http://www.thetestroom.com/webapp";
    switch (browserType){
    case "chrome":
        driver = initChromeDriver(appURL);
        break;
    case "firefox":
        driver = initFirefoxDriver(appURL);
        break;
    default:
        System.out.println(("browser : " + browserType + " is invalid, Launching Firefox as browser of choice.."));
        driver = initFirefoxDriver(appURL);
    }
    return driver;  
}
private static WebDriver initChromeDriver(String appURL) {
    System.out.println("Launching google chrome with new profile..");
    System.setProperty("webdriver.chrome.driver", driverPath
            + "chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize();
    driver.navigate().to(appURL);
    return driver;
}
private static WebDriver initFirefoxDriver(String appURL) {
    System.out.println("Launching Firefox browser..");
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.navigate().to(appURL);
    return driver;
}
public static void closeBrowser(WebDriver driver){
    driver.quit();
}
}  
Below is my project structure:
- My project
- scr/test/java
- package1    
- steps.java
 
 - package2    
- ContactPage.java
 - LandingPage.java
 
 - utils    
- commonFunctions.java
 
 
 - package1    
 - scr/test/resource + myFeature.feature
 - pom.xml
 
 - scr/test/java
 
pom.xml:
<project>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <browser>firefox</browser>
        <appURL>https://www.example.com/webapp</appURL>
        <threads>1</threads>
        <remote>false</remote>
        <seleniumGridURL/>
        <platform/>
        <browserVersion/>
    </properties>
    <dependencies>
        ...
    </dependencies>
</project>