newcoder1010 Posted March 9, 2022 Share Posted March 9, 2022 Hello config.properites file browser = chrome LoadConfig.java file public class LoadConfig{ public static String BrowserType = null; public static boolean load() throws Exception { Properties envProps = new Properties(); envProps.load(new FileInputStream(ConfigFile)); BrowserType = envProps.getProperty("browserType"); // it should get the value from config.properties file } } Test public static void main(String[] args) throws IOException { System.out.println(LoadConfig.BrowserType); } I get null when I run my main method instead I like to see the value "chrome" from the config.properties file. How can I get the value of chrome when I run main method? Link to comment Share on other sites More sharing options...
Ingolme Posted March 9, 2022 Share Posted March 9, 2022 You have to call the load() method at least once before you can access the properties. LoadConfig.load(); System.out.println(LoadConfig.BrowserType); Link to comment Share on other sites More sharing options...
newcoder1010 Posted March 10, 2022 Author Share Posted March 10, 2022 Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now