Hiya,
I'm not new to Java, well not that new, but the class path, packages and such have always been a bit of a blind spot for me. Once I finally get that part working the applications write themselves.
I've written an application that writes large grids as csv files, but I'd like to go a step further and add forumlae and formatting, therefore I've been looking at the Java POI HSSF API (http://jakarta.apache.org/).
I've downloaded the files from here: http://apache.mirror.positive-internet.com/jakarta/poi/release/bin/ and added them to my classpath (I think..), which I have pasted below [and have spaced out for ease of reading];
My Classpath
C:.; C:\Dev\JavaServer\bin;
C:\Dev\JavaLive\io\MySQL\mysql-connector-java-3.1.12-bin.jar;
C:\Dev\JavaLive\io\Excel\poi-2.5.1-final-20040804.jar;
C:\Dev\JavaLive\io\Excel\poi-contrib-2.5.1-final-20040804.jar;
C:\Dev\JavaLive\io\Excel\poi-scratchpad-2.5.1-final-20040804.jar;
%CLASSPATH%
My Test Code
import java.io.*;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class exceltest
{
public exceltest()
{
HSSFWorkbook wb = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
public static void main(String args[])
{
new exceltest();
}
}
I've checked the integrity of the the jar files, and the structure seems intact. Shouldn't adding the three jars to the classpath, as above, allow me to import them as above?
The following errors result at compile:
C:\Dev\JavaLive\exceltest.java:2: package org.apache.poi.hssf.usermodel does not exist
import org.apache.poi.hssf.usermodel.HSSFCell;
^
C:\Dev\JavaLive\exceltest.java:3: package org.apache.poi.hssf.usermodel does not exist
import org.apache.poi.hssf.usermodel.HSSFRow;
^
C:\Dev\JavaLive\exceltest.java:4: package org.apache.poi.hssf.usermodel does not exist
import org.apache.poi.hssf.usermodel.HSSFSheet;
^
C:\Dev\JavaLive\exceltest.java:5: package org.apache.poi.hssf.usermodel does not exist
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
^
C:\Dev\JavaLive\exceltest.java:17: cannot resolve symbol
symbol : class HSSFWorkbook
location: class exceltest
HSSFWorkbook wb = new HSSFWorkbook();
^
C:\Dev\JavaLive\exceltest.java:17: cannot resolve symbol
symbol : class HSSFWorkbook
location: class exceltest
HSSFWorkbook wb = new HSSFWorkbook();
^
6 errors
Tool completed with exit code 1
I've googled, searched the forums and such and have yet to turn up an answer. I assume it's something to do with the classpath as it's not seeing the package? Any help would be very appreciated.
Thanks
David
Message was edited by:
davidrhowells