below exception received during reading properties file.Please help

87 views
Skip to first unread message

AnsumanQA

unread,
Jan 11, 2016, 3:47:57 AM1/11/16
to Selenium Users
My property file name
config.properties


Below is my code,

package helper;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ReadConfigProperty {

public static void main (String[] args) {
InputStream input = ReadConfigProperty.
class.getClassLoader().getResourceAsStream("resource/config.properties");
Properties prop = new Properties( );

try {
prop.load(input);
System.
out.println("url :" + prop.getProperty("url"));
System.
out.println("url:" + prop.getProperty("browser"));
System.
out.println("url:" + prop.getProperty("Username"));
System.
out.println("url :" + prop.getProperty("password"));

}
catch (IOException e) {
e.printStackTrace();
}

}

}

I am receiving below exception during running of ReadConfigProperty : 

Exception in thread "main" java.lang.NullPointerException
	at java.util.Properties$LineReader.readLine(Properties.java:434)
	at java.util.Properties.load0(Properties.java:353)
	at java.util.Properties.load(Properties.java:341)
	at helper.ReadConfigProperty.main(ReadConfigProperty.java:14)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Process finished with exit code 1





Krishnan mahadevan

unread,
Jan 11, 2016, 3:57:01 AM1/11/16
to seleniu...@googlegroups.com
Can you please help keep this forum relevant by ONLY posting queries related to Selenium/Webdriver ?

Your question is a straight forward environment issue.  Java could not find a resource via the claspath

-Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else"

From: AnsumanQA
Sent: ‎11-‎01-‎2016 14:18
To: Selenium Users
Subject: [selenium-users] below exception received during reading propertiesfile.Please help

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/63bde5bf-68cb-4c8d-95f7-277ec778b0bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages