0
votes

I need to access the properties file from my jar when i export to runnable jar.So when i put props file in project root folder in eclipse it is running.But when exported it is not copied.So i wanted it to placed within source folder. So how to access it from source folder.

java.io.FileNotFoundException: config.properties (The system cannot find the fil e specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.(FileInputStream.java:106) at java.io.FileInputStream.(FileInputStream.java:66) at com.my.ashwinsakthi.twitterclient.IplHashtagReader.main(IplHashtagReader.jav a:38)enter image description here

2

2 Answers

0
votes

1,is the properties file packed in the jar file?

2,use MyClass.class.getResourceAsStream("/config.properties") instead.

new File(filename) will searching filename in user.dir

0
votes

I copied the properties file into the jar and placed where my java class files where there and it worked...