I need help getting the Apache POI set up correctly. I downloaded this file: http://mirrors.devlib.org/apache/poi/release/bin/poi-bin-3.2-FINAL-20081019.tar.gz from poi.apache.org, and don't know what to do next?
Where do I put this file? Are there other files I need to download? I hear talk of setting a "Classpath". What is this, and how do I set it up?
I'm running Mac OSX and a current version of Eclipse (set up for Java).
The end result I'm looking for is to be able to execute the following code properly in Java:*
import org.apache.poi.poifs.filesystem.*;
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.extractor.*;
import java.io.*;
public class readDoc
{
public static void main( String[] args )
{
String filesname = "Hello.doc";
POIFSFileSystem fs = null;
try
{
fs = new POIFSFileSystem(new FileInputStream(filesname;
//Couldn't close the braces at the end as my site did not allow it to close
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
String[] paragraphs = we.getParagraphText();
System.out.println( "Word Document has " + paragraphs.length + " paragraphs" );
for( int i=0; i<paragraphs .length; i++ ) {
paragraphs[i] = paragraphs[i].replaceAll("\\cM?\r?\n","");
System.out.println( "Length:"+paragraphs[ i ].length());
}
}
catch(Exception e) {
e.printStackTrace();
}
}
}
*code was found online. The important parts of that include getting the import to work well so that the following methods and class references work as expected.
I'm a newbie to Java so I may need a bit more explanation on how to do some of the basics or what Java jargon means.
Thanks!