iText: how to add the jar file in the class path of linux and windows

ON UBUNTU

I am using IText to one of my projects its a nice technology for creating maniulating pdfs. Here I want to discuss how to add the jar file in the class path of linux.

first download the jar file from http://www.lowagie.com/iText/download.html here.

Now in linux system (I have tried in ubuntu) place the jar file inside any folder suppose named itext.

to set the class path open terminal window type sudo gedit /etc/environment

the environment file is something like this :

PATH=”/usr/local/Java/jdk1.6/bin:.:/usr/local/sbin:/usr/local/bin:

/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11″
LANG=”en_AU.UTF-8″
LANGUAGE=”en_AU:en”
JAVA_HOME=”/usr/local/Java/jdk1.6″
CLASSPATH=”/usr/local/Java/jdk1.6/lib:.”

Add the path_to_your_itext_jar_file at the line CLASSPATH like this

CLASSPATH =”usr/local/Java/jdk1.6/lib: path_to_your_itext_jar_file:.”

then you better restart the system. To test wheather iText is working or not. try this simple code  example:

class HelloWorld{

public static void main(){

Document document = new Document();

PdfWriter.getInstance(document, new FileOutputStream(“HelloWorld.pdf”));

document.open();

document.add(new Paragraph(“Hello World”));

document.close();

}

}

save this file as HelloWorld.java

then in terminal type>> javac HelloWorld.java

then type>> java HelloWorld

now see a pdf is created in the directory where the java file is located.

ON WINDOWS (XP)

Right Click on My Computer Icon. Click Properties.

if there is aleready a variable named CLASSPATH then select and press edit and type the path

of iText.jar file. Suppose the jar file is in d:\itext\iText.jar . add in the value section

d:\itext\iText.jar;

If there is no variable named CLASSPATH the create one by pressing new

classpath

see the above image and try

When you save by press ok it will show here:

createclasspath

Hope this helps ..

Thanks

Advertisements
About

Work is fun!

Tagged with: , , , , , , ,
Posted in Linux, Ubuntu
2 comments on “iText: how to add the jar file in the class path of linux and windows
  1. فرهاد says:

    Thanks man, good luck

  2. Anji Katta says:

    Hi,
    itext is working for java console programs but not working for my servlet application.please help in this regard why its not working web app.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Disclaimer
All content provided on this "tareqalam.com" blog is for informational purposes only. The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner of [tareqalam.wordpress.com] will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
September 2008
M T W T F S S
« Jul   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 25 other followers

%d bloggers like this: