This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes How to include the POI package into java directory ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "How to include the POI package into java directory ?" Watch "How to include the POI package into java directory ?" New topic
Author

How to include the POI package into java directory ?

vikash singhal
Greenhorn

Joined: Mar 22, 2009
Posts: 4
I have been trying to write a program to read excel files using java . I am using POI for the same . Earlier i didnt have the jar for this . but now i have downloaded it .
I am confused as to where to place it so that my program can succesfully compile .
I get an error that says the imported package does not exists ..

import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFRow;


These import statements show an error ... plzz reply asap !!
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
To the point: just in the classpath.

An average IDE calls it "build path". Add the JAR there.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Welcome to JavaRanch.

It doesn't matter where you put those libraries, but you will need to have them in your classpath during compilation and at runtime. Something like "javac -classpath poi-3.2jar MyExcelReadingClass.java"


Ping & DNS - my free Android networking tools app
vikash singhal
Greenhorn

Joined: Mar 22, 2009
Posts: 4
I have tried that using the classpath thing
it doesn't work
can you please help on where the mistake may be ?


Well i tried using eclipse and otherwise also
in eclipse going by the build apth and then adding the external jars isnt solving the problem
is there any other place in the java root directory where i can place the poi package structure for my compiler to find ??
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You have sent me a copy of this reply as private message. You're pushing me to respond. I don't appreciate this this way of communicating. Use the forum where it is intented for. Public discussion about problems. Also, patience is a virtue. We also have a life.

OK, that was it. Continue with the discussion here
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Statements like "it doesn't work" and "it doesn't solve the problem" are very unhelpful: TellTheDetails

But what do you mean by "the poi package structure" - you haven't un-jar-ed the jar files, have you? That would be the wrong thing to do.
vikash singhal
Greenhorn

Joined: Mar 22, 2009
Posts: 4
yes when after appending the jar file in the classpath i cidunt solve the problem i unpacked it to see if my required class exists there in a attempt to go through that way .
i am sorry for that approach though .
Even after adding the jar in eclipse as well as claspath i get the same msg
" import statements not recognised ... "

this isnt the exact msg but it means this .
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15962
    
  19

Vikash, in English, the pronoun "I" is always capitalized. Also the period (.) at the end of a sentence should not be preceeded by a space. Paying attention to the little illogical details of the language makes you look more professional.

Eclipse can be confusing since Eclipse is a Java program that contains and runs Java programs. However, the Eclipse classpath applies only to the Eclipse program itself, not to the applications that are being maintained in Eclipse.

The classpaths for those applications are contained the the ".classpath" file that is one of 2 files that define an Eclipse Java project - the other file is named ".project". The .classpath file is maintained as follows:

1. In the Navigator view, right-click the icon that defines the root of the project (has the project's name). Select the bottom-most item (Properties). This will display the Project Properties Dialog.

2. On the Project Properties dialog select Java Build Path. This will display a series of tabs.

3. Select the Libraries tab. This is where you define the POI jars to the project. At a minimum, it will have a JRE System Library already defined in it (otherwise even java.lang.Object will be show an error as an undefined type).

Where you keep the libraries is up to you. I often just make a "lib" directory in the project, but for Eclipse, the exact location isn't important except for one thing - if you keep the POI jars within the project, use the "Add JARS" button to define them to the project. Otherwise use the "Add External JARS" button. Make sure that ll the POI jars are displayed in this dialog, then click OK to finalize their definition.

That's all you should need to be able to edit and test your POI app in Eclipse. I'll leave the details of setting up the app to run outside of Eclipse for a later time.


Customer surveys are for companies who didn't pay proper attention to begin with.
vikash singhal
Greenhorn

Joined: Mar 22, 2009
Posts: 4
Thank You so much for the reply.
I will take care of putting my queries in a better way in the future.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to include the POI package into java directory ?
 
Similar Threads
How to use POI
Excel document created using HSSF POI API not opening in Windows7 but opening in Win XP
Opening an Excel file
Error in POI
Getting java.lang.NoClassDefFoundError while trying POI