public class ABC {
public ABC() {
File file = new File("xyz.xml");
but when I run my jar as follows:
java -jar filename.jar arguments....
then it is showing error:
java.lang.IllegalArgumentException: InputStream cannot be null
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:120)
at com.ensarm.niidle.web.proxy.ABC.<init>(ABC.java:47)
How can I fix it?
If you need to read file content in JARs, you can not use File class directly. Using ClassLoader to load it:
// for example read the SeleniumConfiguration.xml in the default package
InputStream input = SeleniumConfiguration.class.getResourceAsStream("/SeleniumConfiguration.xml");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With