Exception in thread "main" java.lang.IllegalArgumentException: in must not be null
<p>I tried to use OpenNLP library to use its sentencedetector and I try to write the following code but I got exception which is related to the address of this <strong>en-sent.bin</strong> file but I do not know how to address this file.</p>

<pre><code>import java.io.*;
import java.net.URL;

import opennlp.tools.sentdetect.SentenceDetectorME;
import opennlp.tools.sentdetect.SentenceModel;
public class SentenceDetect 
{

       private SentenceDetectorME sentenceDetector;

        public void init()
        {
            /** Load and initialize the sentence detection model */

            InputStream modelIn = null;
            SentenceModel model = null;

            try {

                modelIn = SentenceDetect.class.getClassLoader().getResourceAsStream("Tokenizer/models/en-sent.bin");
                model = new SentenceModel(modelIn); //*&lt;- line 36*
                }
            catch (IOException e) 
                {
                  e.printStackTrace();
                }
            finally {
                  if (modelIn != null) {
                        try {
                          modelIn.close();
                        }
                        catch (IOException e) {}
                      }
                }

            sentenceDetector = new SentenceDetectorME(model);

        }

        public String[] getSentences(String longSentence)
        {
            return sentenceDetector.sentDetect(longSentence);
        }

}
</code></pre>

<p>The Main class:</p>

<pre><code>public static void main(String[] args)
    {

       SentenceDetect d = new SentenceDetect();


       d.init();   ///*&lt;- line 10*

       String[] s = d.getSentences("This is sentence #1. This is Sentence #2");

       System.out.println( s[0] );  // Should be the first sentence

       System.out.println( s[1] );  // Should be the second sentence

    }
</code></pre>

<p>The following image shows the hierarchically of my project (sorry about the picture I use Ubuntu but I do not know have use print-screen button here):</p>

<p><a href="https://i.stack.imgur.com/feHO7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/feHO7.jpg" alt="enter image description here"></a></p>

<p>The whole error is:</p>

<pre><code>`Exception in thread "main" java.lang.IllegalArgumentException: in must not be null!
at opennlp.tools.util.model.BaseModel.&lt;init&gt;(BaseModel.java:179)
at opennlp.tools.sentdetect.SentenceModel.&lt;init&gt;(SentenceModel.java:95)
at SentenceDetect.init(SentenceDetect.java:36)
at Main.main(Main.java:10)`
</code></pre>

<p>I tried these paths but I got the same error:</p>

<ul>
<li>/Tokenizer/models/en-sent.bin </li>
<li>/models/en-sent.bin</li>
<li>models/en-sent.bin</li>
<li>/home/suri/workspace/2/Tokenizer/models/en-sent.bin</li>
</ul>