Abhishek Abhishek - 1 year ago 96
Java Question

Add properties file for custom plugin in Nutch

I'm a beginner in Nutch. I have done crawling, created a custom plugin based on different tutorials. For a particular task, my Java class have to use a properties file named

for some tasks. I've getting a NullPointerException on the following code.

Properties property = new Properties();
InputStream input = getClass().getResourceAsStream("sample.properties");

I don't know where to place this properties file, because it doesn't moves to the compiled jar after compiling with ant. Currently I'm placing at the same directory of java class. Any help will be appreciated.

Answer Source

I just solved by adding a copy task in plugin's build.xml as :

<copy todir="${build.classes}">
    <fileset dir="${src.dir}" includes="**/*.properties"/>

It copies the properties file to the compiled jar and issue was solved. Cheers !!


I just used another method also. Moved the properties file to conf directory and get the input in Parsefilter by,

Properties property = new Properties();
InputStream input = ClassLoader.getSystemResourceAsStream("sample.properties");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download