× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



hi Jack,

On 3/5/2012 2:12 PM, Jack Tucky wrote:
I downloaded the source. I should have downloaded the JAR, correct?


Right... the source is source code that you'll have to compile before you can use it. If you get the one that's referred to as a "pre-built binary" it means that they've already compiled it for you.

I just tried downloading the pre-built binary, and it came as a JAR file. So, there's nothing to extract.

I would recommend creating an IFS directory where you want to store stuff like this. For example, maybe you want to create a Java directory, and inside that, create a PDFBOX directory?

mkdir dir('/java')
mkdir dir('/java/pdfbox')

Then put the pdfbox-1.6.0.jar file in that /java/pdfbox directory. Now that you've done that, you need to tell Java (not RPG. RPG doesn't know how to run Java code) how to find the JAR file. This is done with the CLASSPATH environment variable. If this PDFBOX is the only Java class you want to use, then you'd do this:

ADDENVVAR ENVVAR(CLASSPATH) +
VALUE('/java/pdfbox/pdfbox-1.6.0.jar')

If you want the variable to still be there after you sign off and back on again, make it a system level variable:

ADDENVVAR ENVVAR(CLASSPATH) +
VALUE('/java/pdfbox/pdfbox-1.6.0.jar') +
LEVEL(*SYS)

If you have multiple JAR files (or directories containing .class files) that you'd like to make available to your application, you can list them all in your CLASSPATH at once. To do that, simply separate each JAR file from the next using a colon. (But, make sure there are no extra spaces)

ADDENVVAR ENVVAR(CLASSPATH) +
VALUE('/java/pdfbox/pdfbox-1.6.0.jar:/java/poi3.6+
/poi-3.6-20091214.jar:/java/jdbc/mysql-conn+
ector-java-5.1.12-bin.jar') +
LEVEL(*SYS)

..etc...

The CLASSPATH must be set before you start the JVM. (i.e. before the first RPG program in the job uses Java. Once any RPG program in the job uses java, the JVM is loaded and it will not check the CLASSPATH again.)

The problem with using /QIBM/UserData/Java400/ext is that it considers the JAR files to be "extensions" to the Java run-time environment. Therefore, every single Java program on the system will load the the JAR files in that directory, automatically. (with or without a classpath)

When you use the "ext" directory, you can only have one version of a given JAR file (or product) available on your system. you can't have some jobs using one version, and others using another version, because whatever is in "ext" always loads automatically, no matter what.

By contast, when you use CLASSPATH (and the JAR file is not in 'ext') this problem is gone. For example (hypothetically), I may have some older 3rd-party software using PDFBOX 1.2 on my system, but my new RPG program might want to use PDFBOX 1.6.0. With CLASSPATH that's no problem. With "ext", it's impossible to do that.

-SK

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.