简体   繁体   中英

Configuring Classpath on IBM i (AS400) server

I am trying to setup our IBM i server to connect to an SQL server. The necessary .JAR driver file has been downloaded an uploaded to the server. We have been following these instructions .

Now we are trying to set the classpath environment variable. It currently looks as below:

'/QIBM/ProdData/OS400/jt400/lib/jt400Native.jar:/QIBM/ProdData/OS400/jt400/lib/jt400Native11x.jar:/QIBM/ProdData/OS400/jt400/MRI2924/jt400Mri.jar:. '

The jar file is at location /java/jdbc/jtds-1.3.1.jar. It seems all i need to do is append this to the classpath string. However, I am confused that there is an extra period ('.') at the end of the string following 'jar:'

Is it really necessary or was it inserted by mistake? Please advise how i can add this jar file to the class path.

There are other java stuff running on the server and I absolutely cannot afford to mess up anything. I know even the slightest change to the classpath can blow up things.

The WRKENVVAR command has an option to work with only Job level variables. CAn i modify this at my job level without impacting things other people do?

Edit 01: Based on the first comment below, I understand that in this case, the '.' is specified at the very end instead of the beginning of the string as I could see in most examples.

So can I modify the class path as below?

'/QIBM/ProdData/OS400/jt400/lib/jt400Native.jar:/QIBM/ProdData/OS400/jt400/lib/jt400Native11x.jar:/QIBM/ProdData/OS400/jt400/MRI2924/jt400Mri.jar:/java/jdbc/jtds-1.3.1.jar:.'

As Boris stated in a comment:

The . stands for the current directory where from the command is issued which means every *.jar file in it will be added to the classpath.

But I don't see how that would be useful because each user will have a different current directory, and on IBM i that current directory will likely be the user's home directory in the IFS. Since RPG programs do not run from the IFS, this is not likely to change at all. So you may be safe to remove the . from the classpath.

Another thing to remember is that you can't change the classpath once you start the JVM. Since each job can have at most one JVM, my practice is to set the classpath and start the JVM at the beginning of each job that will need it. I do that with a CL program that I have created specifically for the purpose.

Here is a sample SETUPJVM program that you can use to setup and initiate the JVM:

         PGM
         DCLPRCOPT  DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR(MYBNDDIR) +
                    USRPRF(*OWNER)
         DCL        VAR(&POINTER) TYPE(*PTR)

         ADDENVVAR  ENVVAR(CLASSPATH) +
                      VALUE('+
                        /java/poi-3.14/poi-3.14-mx.jar:+
                        /java/poi-3.14/poi-ooxml-3.14-mx.jar:+
                        /java/poi-3.14/ooxml-schemas-1.3.jar:+
                        /java/poi-3.14/lib/commons-codec-1.10.jar:+
                        /java/poi-3.14/lib/commons-logging-1.2.jar:+
                        /java/poi-3.14/lib/log4j-1.2.17.jar:+
                        /java/poi-3.14/ooxml-lib/xmlbeans-2.6.0.jar:+
                        /java/poix/poi-extend.jar:+
                        /java/javamail/javax.mail.jar:+
                        /java/rpgmail/rpgmail.jar:+
                        /java/prod/lib/mxSqlSvrJdbc.jar:+
                        /java/prod/lib/sqljdbc.jar:+
                        /java/prod/classes/cribMaster+
                      ') REPLACE(*YES)
         ADDENVVAR  ENVVAR(QIBM_RPG_JAVA_PROPERTIES) +
                      VALUE('+
                        -Djava.awt.headless=true;+
                        -Djava.net.preferIPv4Stack=true;+
                      ') REPLACE(*YES)

         ADDENVVAR  ENVVAR(QIBM_USE_DESCRIPTOR_STDIO) VALUE('Y') REPLACE(*YES)
         ADDENVVAR  ENVVAR(JAVA_HOME) +
                      VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk80/32bit'+
                      ) REPLACE(*YES)
         ADDENVVAR  ENVVAR(QIBM_RPG_JAVA_EXCP_TRACE) VALUE('Y') REPLACE(*YES)

         CALLPRC    PRC(START_JVM) RTNVAL(&POINTER)
OUT:     ENDPGM

This is a CLLE, and calls a procedure ( START_JVM ) from Scott Kelment's HSSFR4 service program found here . Note that the procedure in Scotts service program is not exported, but all you need to do is modify the source to export the procedure.

Customizing SETUPJVM for your personal use:

  1. You will want to set BNDDIR() to reference your own binding directory.
  2. You will want to adjust the classpath to include the jars you are using. This one assumes POI and RPGMAIL.
  3. You may want to select a different JVM.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM