title: Java program uses or overrides a deprecated API?
body: <p>I have written a program that is compiled and run in Netbeans and Eclipse without any problem. But when I try to compile it in command line via:</p>
  
  <pre><code>javac -classpath .:lucene-core-3.4.0.jar Indexer.java
  </code></pre>
  
  <p>I get the error:</p>
  
  <pre><code>Note: Indexer.java uses or overrides a deprecated API.
  Note: Recompile with -Xlint:deprecation for details.
  </code></pre>
  
  <p>When I try to compile with -Xlint:deprecation option I get:</p>
  
  <pre><code>javac -classpath .:lucene-core-3.4.0.jar Indexer.java -Xlint:deprecation
  Indexer.java:14: warning: [deprecation] org.apache.lucene.index.IndexWriter.MaxFieldLength in org.apache.lucene.index.IndexWriter has been deprecated
  import org.apache.lucene.index.IndexWriter.MaxFieldLength;
                                            ^
  1 warning
  </code></pre>
  
  <p>My source code seems to be pure and without any problem! can anyone help me compile and run it in command line?</p>
  
  <p>Code</p>
  
  <pre><code>import java.io.File;
  import java.io.FileFilter;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.File;
  import java.io.FileReader;
  import java.io.BufferedReader;
  import org.apache.lucene.index.IndexWriter;
  import org.apache.lucene.index.IndexWriter.MaxFieldLength;
  import org.apache.lucene.document.Field;
  import org.apache.lucene.document.Document;
  import org.apache.lucene.store.RAMDirectory;
  import org.apache.lucene.analysis.standard.StandardAnalyzer;
  import org.apache.lucene.analysis.StopAnalyzer;
  import org.apache.lucene.index.IndexReader;
  import org.apache.lucene.store.Directory;
  import org.apache.lucene.store.FSDirectory;
  import org.apache.lucene.util.Version;
  import org.apache.lucene.index.TermFreqVector;
  
  public class Indexer {
  
      public static void main(String[] args) throws Exception {
          // TODO code application logic here
  
          //Indexing begins
              String indexDir;
              String dataDir;
              if (args.length != 2) {
                      dataDir = new String("/home/norc/Ranking/Hamshahri/Data/");
                      indexDir = new String("/media/5E62D9BD62D99A5B/indexes/");
              //throw new IllegalArgumentException("Usage: java " + Indexer.class.getName() + " &lt;index dir&gt; &lt;data dir&gt;");
          }
                  else {
                      dataDir = args[0];
                      indexDir = args[1];
                  }
          long start = System.currentTimeMillis();
          Indexer indexer = new Indexer(indexDir);
          int numIndexed;
          try {
              numIndexed = indexer.index(dataDir, new TextFilesFilter());
          } finally {
              indexer.close();
          }
          long end = System.currentTimeMillis();
          System.out.println("Indexing " + numIndexed + " files took " + (end - start) + " milliseconds");
  
      }
  
      private IndexWriter writer;
  
      @SuppressWarnings("deprecation")
      public Indexer(String indexDir) throws IOException {
          Directory dir = FSDirectory.open(new File(indexDir));
          writer = new IndexWriter(dir,
               new StopAnalyzer(Version.LUCENE_34, new File("/home/norc/Ranking/Hamshahri/stopwords.txt")),
               true,
               IndexWriter.MaxFieldLength.UNLIMITED);
      }
  
      public void close() throws IOException {
          writer.close();
      }
  
      public int index(String dataDir, FileFilter filter) throws Exception {
          File[] dires = new File(dataDir).listFiles();
          for (File d: dires) {
              if (d.isDirectory()) {
              File[] files = new File(d.getAbsolutePath()).listFiles();
              for (File f: files) {
                  if (!f.isDirectory() &amp;&amp;
                  !f.isHidden() &amp;&amp;
                  f.exists() &amp;&amp;
                  f.canRead() &amp;&amp;
                  (filter == null || filter.accept(f))) {
                      indexFile(f);
                  }
              }
              }
          }
          return writer.numDocs();
      }
  
      private static class TextFilesFilter implements FileFilter {
          public boolean accept(File path) {
              return path.getName().toLowerCase().endsWith(".txt");
          }
      }
  
  
      protected Document getDocument(File f) throws Exception {
          Document doc = new Document();
          if (f.exists()) {
          doc.add(new Field("contents", new FileReader(f), Field.TermVector.YES));
          doc.add(new Field("path", f.getAbsolutePath(), Field.Store.YES, Field.Index.NOT_ANALYZED));
          String cat = "WIR";
          cat = f.getAbsolutePath().substring(0, f.getAbsolutePath().length()-f.getName().length()-1);
          cat = cat.substring(cat.lastIndexOf('/')+1, cat.length());
          //doc.add(new Field("category", cat.subSequence(0, cat.length()), Field.Store.YES));
          //System.out.println(cat.subSequence(0, cat.length()));
          }
          return doc;
      }
  
      private void indexFile(File f) throws Exception {
          System.out.println("Indexing " + f.getAbsolutePath());
          Document doc = getDocument(f);
          writer.addDocument(doc);
      }
  
  }
  </code></pre>