English 中文(简体)
Apache POI Word - Installation
  • 时间:2024-11-03

Apache POI Word - Installation


Previous Page Next Page  

This chapter takes you through the process of setting up Apache POI on Windows and Linux based systems. Apache POI can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.

System Requirements

JDK Java SE 2 JDK 1.5 or above
Memory 1 GB RAM (recommended)
Disk Space No minimum requirement
Operating System Version Windows XP or above, Linux

Let us now proceed with the steps to install Apache POI.

Step 1: Verify your Java Installation

First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the two commands depending on the platform you are working on.

If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.

Platform Command Sample Output
Windows

Open command console and type −

>java -version

java version "11.0.11" 2021-04-20 LTS

Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194)

Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode)

Linux

Open command terminal and type −

$java -version

java version "11.0.11" 2021-04-20 LTS

Open JDK Runtime Environment 18.9 (build 11.0.11+9-LTS-194)

Open JDK 64-Bit Server VM (build 11.0.11+9-LTS-194, mixed mode)

Step 2: Set your Java Environment

Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,

Sr.No. Platform & Description
1

Windows

Set JAVA_HOME to C:ProgramFilesjavajdk11.0.11

2

Linux

Export JAVA_HOME = /usr/local/java-current

Append the full path of Java compiler location to the System Path.

Sr.No. Platform & Description
1

Windows

Append the String "C:Program FilesJavajdk11.0.11in" to the end of the system variable PATH.

2

Linux

Export PATH = $PATH:$JAVA_HOME/bin/

Execute the command java -version from the command prompt as explained above.

Step 3: Install Apache POI Library

Download the latest version of Apache POI from https://poi.apache.org/download.html and unzip its contents to a folder from where the required pbraries can be pnked to your Java program. Let us assume the files are collected in a folder on C drive.

Add the complete path of the required jars as shown below to the CLASSPATH.

Sr.No. Platform & Description
1

Windows

Append the following strings to the end of the user variable

CLASSPATH −

C:poi-bin-5.1.0poi-5.1.0.jar;

C:poi-bin-5.1.0poi-ooxml-5.1.0.jar;

C:poi-bin-5.1.0poi-ooxml-full-5.1.0.jar;

C:poi-bin-5.1.0pbcommons-codec-1.15.jar;

C:poi-bin-5.1.0pbcommons-collections4-4.4.jar;

C:poi-bin-5.1.0pbcommons-io-2.11.0.jar;

C:poi-bin-5.1.0pbcommons-math3-3.6.1.jar;

C:poi-bin-5.1.0pblog4j-api-2.14.1.jar;

C:poi-bin-5.1.0pbSparseBitSet-1.2.jar;

Cpoi-bin-5.1.0ooxml-pbcommons-compress-1.21.jar

Cpoi-bin-5.1.0ooxml-pbcommons-logging-1.2.jar

Cpoi-bin-5.1.0ooxml-pbcurvesapi-1.06.jar

Cpoi-bin-5.1.0ooxml-pbslf4j-api-1.7.32.jar

Cpoi-bin-5.1.0ooxml-pbxmlbeans-5.0.2.jar

2

Linux

Export CLASSPATH = $CLASSPATH:

/usr/share/poi-bin-5.1.0/poi-5.1.0.jar.tar:

/usr/share/poi-bin-5.1.0/poi-ooxml-5.1.0.tar:

/usr/share/poi-bin-5.1.0/poi-ooxml-full-5.1.0.tar:

/usr/share/poi-bin-5.1.0/pb/commons-codec-1.15.jar.tar:

/usr/share/poi-bin-5.1.0/pb/commons-collections4-4.4.tar:

/usr/share/poi-bin-5.1.0/pb/commons-io-2.11.0.tar:

/usr/share/poi-bin-5.1.0/pb/commons-math3-3.6.1.tar:

/usr/share/poi-bin-5.1.0/pb/log4j-api-2.14.1.tar:

/usr/share/poi-bin-5.1.0/pb/SparseBitSet-1.2.tar:

/usr/share/poi-bin-5.1.0/ooxml-pb/commons-compress-1.21.tar:

/usr/share/poi-bin-5.1.0/ooxml-pb/commons-logging-1.2.tar:

/usr/share/poi-bin-5.1.0/ooxml-pb/curvesapi-1.06.tar:

/usr/share/poi-bin-5.1.0/ooxml-pb/slf4j-api-1.7.32.tar:

/usr/share/poi-bin-5.1.0/ooxml-pb/xmlbeans-5.0.2.tar:

Advertisements