You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Mirko Vukovic <mi...@gmail.com> on 2014/08/18 23:04:47 UTC

import fails

Hello,

I am having a lot of trouble writing a simple POI app to access an Excel
file.  My Java background is next to nil (I use common lisp), except for
helping my kids with beginning programming courses (I was learning along
with them).

I downloaded and extracted POI, and wrote a small java file, modeled after a
tutorial I found on the web.  It is currently littered with various import
attempts:
==================
//import org.apache.poi.hssf.usermodel.HSSFSheet;
//import poi;
//import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import org.apache.poi.ss.usermodel.charts; // found in jar file
//import org.apache.poi.xssf.eventusermodel.XSSFReader;
//import org.apache.poi.xssf.model.SharedStringsTable;
//import org.apache.poi.openxml4j.opc.OPCPackage;
public class poiLink{
}
===================

For compilation I use:
/c/Program\ Files/Java/jdk1.8.0_11/bin/javac.exe -cp
'.;:c/java-libs/poi-3.10.1/poi-3.10.1-20140818.jar' poiLink.java

where for the class path I use the jar file path in the downloaded POI distro. 

The error is:
poiLink.java:5: error: package org.apache.poi.ss.usermodel does not exist
import org.apache.poi.ss.usermodel.charts;
                                  ^
1 error

Am I incorrectly specifying the jar file?  Is the syntax incorrect?  I
looked at Oracle, stack overflow, tried many things, and I must be missing
something obvious.

Thanks,

Mirko




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: import fails

Posted by Mirko Vukovic <mi...@gmail.com>.
Mirko Vukovic <mirko.vukovic <at> gmail.com> writes:

> 
> Andreas Beeker <andreas.beeker <at> gmx.de> writes:
> 
> > 
> > Hi Mirko,
> > 
> > is this just a typo (while writing the email) or the reason for not
> finding the jar file??
> > 
> > instead of:
> > 
> > /c/Program\ Files/Java/jdk1.8.0_11/bin/javac.exe -cp
> > '.;:c/java-libs/poi-3.10.1/poi-3.10.1-20140818.jar' poiLink.java
> > 
> > use: (twist :c -> c:)
> > 
> > "c:\Program Files\Java\jdk1.8.0_11\bin\javac.exe" -cp
> > ".;c:\java-libs\poi-3.10.1\poi-3.10.1-20140818.jar" poiLink.java
> > 

Problem solved:  As Andreas pointed out, I was using incorrect path to the
jar file: typing :c instead of c: (careless typing mistake)

After adding the javac.exe bin directory to path, on the command line the
following works:

> javac -cp '.;c:/java-libs/poi-3.10.1/poi-3.10.1-20140818.jar' poiLink.java

with poiLink.java being
=======================
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class poiLink{
}
=======================


(Again, this is bash terminal on Cygwin64 on Windows 7)

Thank you, Andreas.

Mirko



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: import fails

Posted by Mirko Vukovic <mi...@gmail.com>.
Andreas Beeker <andreas.beeker <at> gmx.de> writes:

> 
> Hi Mirko,
> 
> is this just a typo (while writing the email) or the reason for not
finding the jar file??
> 
> instead of:
> 
> /c/Program\ Files/Java/jdk1.8.0_11/bin/javac.exe -cp
> '.;:c/java-libs/poi-3.10.1/poi-3.10.1-20140818.jar' poiLink.java
> 
> use: (twist :c -> c:)
> 
> "c:\Program Files\Java\jdk1.8.0_11\bin\javac.exe" -cp
> ".;c:\java-libs\poi-3.10.1\poi-3.10.1-20140818.jar" poiLink.java
> 
> I would recommend you to install an IDE such as Eclipse or IntelliJ. At
least link
> and compilation errors can be minimized by those.
> 
> Normally you just type the classname (and press some shortcut) and the IDE
cares about the imports.
> 
> Andi.
> 

I am Windows 7, but use Cygwin (unix style interface).  Thus the pathnames
are unix style except for the jar path, which is on C:.  I use the `;' as
path separator on Windows.

I was avoiding Eclipse - one more thing to learn.  

Instead of this setup, I will go to the windows command interface, so I at
least I am consistent there.

Mirko



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: import fails

Posted by Andreas Beeker <an...@gmx.de>.
Hi Mirko,

is this just a typo (while writing the email) or the reason for not finding the jar file??

instead of:

/c/Program\ Files/Java/jdk1.8.0_11/bin/javac.exe -cp
'.;:c/java-libs/poi-3.10.1/poi-3.10.1-20140818.jar' poiLink.java

use: (twist :c -> c:)

"c:\Program Files\Java\jdk1.8.0_11\bin\javac.exe" -cp
".;c:\java-libs\poi-3.10.1\poi-3.10.1-20140818.jar" poiLink.java

I would recommend you to install an IDE such as Eclipse or IntelliJ. At least link
and compilation errors can be minimized by those.

Normally you just type the classname (and press some shortcut) and the IDE cares about the imports.

Andi.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org