• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to include the POI package into java directory ?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 !!
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To the point: just in the classpath.

An average IDE calls it "build path". Add the JAR there.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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"
 
vikash singhal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 .
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
vikash singhal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You so much for the reply.
I will take care of putting my queries in a better way in the future.
 
reply
    Bookmark Topic Watch Topic
  • New Topic