I want to display data in a pdf format. I've downloaded 3 jars & they're put in my jre/lib/ext/ path. The 3 jars are: iText-2.1.4.jar iText-rtf-2.1.4.jar iText-rups-2.1.4.jar
Sun's Java installers used to sometimes (often) put a copy of java.exe into your C:\WINDOWS directory (or someplace along those lines) which is used by the Java Plug-in. This then leads to a situation where your path contains javac.exe from a JDK you've installed, but java.exe in C:\WINDOWS (or maybe in a JRE you've installed that's earlier on your path.)
In any case, examine your system closely; make sure that the java.exe you're running is the one that you expect. If it's not, then it won't be looking in that "ext" directory for extensions.
First of all, please don't call Ernest "Hill". It's not his first name nor his last name - it's part of his last name. If you go around calling people by their last name only (which is quite uncommon in Europe and the US), then at least use "Friedman-Hill". Or just be lazy and call him EFH like everyone else does
Now back to the problem. You may not be using the JRE you think you are. When you install the JDK, it actually installs 2 JREs: one inside the JDK folder (in a folder simply called jre) and one in C:\Program Files (usually). So if you have put them in C:\jdk1.5.0\jre\lib\ext, the other JRE (C:\Program Files\Java\xxxxx) will not see those libraries. You have to copy the files to that folder as well.
What I said was that the java.exe you're running may not actually be looking to the JDK extensions directory where you've installed iText.
And actually, I only said "may not" just to be nice, because I will actually guarantee you that what I've described is precisely the problem.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Thanks RP & EFH. Now after putting all the jar's in both the exts(JRE of program files & in C:\jdk1.5) it's working fine. If I have the jars simply in my classpath C:\jdk1.5\lib then it was throwing the same error at run time Why? Regards.
Note: Dear EFH please excuse me on your name I've used in the last post.
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
Now when I include the jar files in my classpath(C:\jdk1.5\lib) & compile , the program is not getting compiled. The error trace is:
It shows the some pdf related classes are not found, which is not the case when we include the jar in jre\ext. Why is this so?
2) But other normal built-in classes are working at runtime. How?
You should not be misusing JDK's /lib folder to place 3rd party JAR's in. It makes your application less portable. You would also get more trouble like as you're struggling with now when you're using multiple JDK's and/or ever going to reinstall or upgrade it.
Just use the -classpath or -cp argument for that.
And to execute it: To save effort in typing you can easily wrap in a batch or shell file, depending on the OS used. [ December 19, 2008: Message edited by: Bauke Scholtz ]
Personally, I use ANT tasks to keep straight all the various versions of Java and toolkits present on my machine. ANT lets you define "properties" that get substituted into tasks like:
used to compile like:
Yes, this is a bit more work than defining batch files with classpath variables but it is more general and worth the learning curve.
Thanks Bauke Scholtz & William Brogden for their valuable opinions. Now I've understood
Don't put third party jar in jdk\lib. Instead use i) javac -cp command or java -cp command. ii) ant by using the properties attribute to include third party jars.
Now now need two clarifications
1)
You should not be misusing JDK's /lib folder to place 3rd party JAR's in. It makes your application less portable.
Now do you mean to say since the client's JVM & more specifically jdk\lib won't be having those third party jars , it makes our application less portable or is there any specific reasons.
2)
To save effort in typing you can easily wrap in a batch or shell file, depending on the OS used.
A batch file is similar to a text file only difference being saved in the extension .bat. Here you are saying to wrap up the command javac & java in batch file. Okay but using this we can run only one class right .
3)
You would also get more trouble like as you're struggling with now when you're using multiple JDK's
Can we use multiple JDK's in our application if yes normally in what situations they would opt for one
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12324
1
posted
0
1. Remember that yours may not be the only Java application your client is running. Placing 3rd party jars in the standard locations may break other applications
2. Thats the idea, one batch or shell file per application.
3. I distinguish between an application compiled so that it can run under several different Java editions and "using multiple JDKs" at the same time. What are you talking about?
Bill
ramya narayanan
Ranch Hand
Joined: Oct 06, 2008
Posts: 338
posted
0
3. I distinguish between an application compiled so that it can run under several different Java editions and "using multiple JDKs" at the same time. What are you talking about?
I'm talking about the purpose of using multiple jdk's at the same time. Regards.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12324
1
posted
0
Sounds like a recipe for disaster to me even if you could do it.