title: NLTK was unable to find the java file! for Stanford POS Tagger
body: <p>I have been stuck trying to get the Stanford POS Tagger to work for a while. From an <a href="https://stackoverflow.com/questions/34726200/nltk-was-unable-to-find-stanford-postagger-jar-set-the-classpath-environment-va">old SO post</a> I found the following (slightly modified) code:</p>
  
  <pre><code>stanford_dir = 'C:/Users/.../stanford-postagger-2017-06-09/'
  
  from nltk.tag import StanfordPOSTagger
  #from nltk.tag.stanford import StanfordPOSTagger # I tried it both ways
  from nltk import word_tokenize
  
  # Add the jar and model via their path (instead of setting environment variables):
  jar = stanford_dir + 'stanford-postagger.jar'
  model = stanford_dir + 'models/english-left3words-distsim.tagger'
  
  pos_tagger = StanfordPOSTagger(model, jar, encoding='utf8')
  
  text = pos_tagger.tag(word_tokenize("What's the airspeed of an unladen swallow ?"))
  print(text)
  </code></pre>
  
  <p>However, I get the following error:</p>
  
  <pre><code>LookupError: 
  
  ===========================================================================
  NLTK was unable to find the java file!
  Use software specific configuration paramaters or set the JAVAHOME environment variable.
  ===========================================================================
  </code></pre>
  
  <p>I don't know what java file it is talking about. I'm sure it's finding the right files because if I change the path to something incorrect I get a different error:</p>
  
  <pre><code>LookupError: Could not find stanford-postagger.jar jar file at C:/Users/.../stanford-postagger-2017-06-09/sstanford-postagger.jar
  </code></pre>
  
  <p>What java file is missing? How do I get the Stanford POS tagger to work?</p>
  
  <p>EDIT:</p>
  
  <p>I went to this <a href="https://gist.github.com/alvations/0ed8641d7d2e1941b9f9" rel="noreferrer">link for Stanford NLP on Windows</a> and tried:</p>
  
  <p>(Second EDIT - adding the installation procedures):</p>
  
  <pre><code>import urllib.request
  import zipfile
  urllib.request.urlretrieve(r'http://nlp.stanford.edu/software/stanford-postagger-full-2015-04-20.zip', r'C:/Users/HMISYS/Downloads/stanford-postagger-full-2015-04-20.zip')
  zfile = zipfile.ZipFile(r'C:/Users/HMISYS/Downloads/stanford-postagger-full-2015-04-20.zip')
  zfile.extractall(r'C:/Users/HMISYS/Downloads/')
  # End second edit
  
  from nltk.tag.stanford import StanfordPOSTagger
  # Trying on an older version
  _model_filename = r'C:/Users/HMISYS/Downloads/stanford-postagger-full-2015-04-20/models/english-bidirectional-distsim.tagger'
  _path_to_jar = r'C:/Users/HMISYS/Downloads/stanford-postagger-full-2015-04-20/stanford-postagger.jar'
  st = StanfordPOSTagger(model_filename=_model_filename, path_to_jar=_path_to_jar)
  text = st.tag(nltk.word_tokenize("What's the airspeed of an unladen swallow ?"))
  print(text)
  </code></pre>
  
  <p>but I got the same error. Based on <a href="https://gist.github.com/alvations/e1df0ba227e542955a8a" rel="noreferrer">this post</a> I set my path variables with the following:</p>
  
  <pre><code>set STANFORDTOOLSDIR=$HOME
  set CLASSPATH=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/stanford-postagger.jar
  set export STANFORD_MODELS=$STANFORDTOOLSDIR/stanford-postagger-full-2015-04-20/models
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>NLTK was unable to find stanford-postagger.jar! Set the CLASSPATH environment variable.
  </code></pre>