Luciano Oliveira
Luciano Oliveira

Reputation: 37

IBM i (AS400) JVM - Is it possible to define where the JVM looks for .jar files?

We bought a solution from a provider a couple of years ago, droped the .jar file in the standard location in IFS /QIBM/UserData/Java400/ext/ and we have been working correclty ever since with this.

However a couple of months ago the provider released a new .jar with some new functions we would like to use. However they also changed the names of several classes and methods that we are using.

So what we were thinking of doing, if possible, is define a path on which the old programs when they need to use that .jar look for that .jar in the defined path. And for the new programs that we want to use the new .jar file we wanted to have different path for that.

At this point I don't know if this is possible to do. I have been searching everywhere for this information without luck. So if someone around here as some clue it would be fantastic.

Thank you for your time.

Edit: So I was reading through your advices and I have these coments. I already asked the supplier for assistance but since this wasn't designed for AS400 they don't provide support. I tested the possibility of the classpath. I deleted the files from the /QIBM/UserData/Java400/ext/ and put them in /QIBM/JARS/old/ then I created a CL that did this:

ADDENVVAR ENVVAR(CLASSPATH) VALUE('/QIBM/JARS/old') REPLACE(*YES)

After I first executed this new CL then I tried a program that would use the .jar that I had in the location /QIBM/JARS/old and I got the error of the class not found. So either I did something wrong or this isn't actually a solution.

HotLicks do you mean that it is not possible to have users A1 and B1, and A1 using /QIBM/JARS/old/A.jar and B1 using /QIBM/JARS/new/A.jar at the same time?

Upvotes: 1

Views: 1638

Answers (2)

jweberhard
jweberhard

Reputation: 586

You probably want to redefine your extensions classpath when running with the new version of the jar.

  1. Create a new directory -- i.e. /QIBM/UserData/MyJava/ext

  2. Copy the jars files you need from /QIBM/UserData/Java400/ext to /QIBM/UserData/MyJava/ext

  3. Add your new jar file to /QIBM/UserData/MyJava/ext.

  4. When starting the Java program, use the following define to set the extensions directory: -Djava.ext.dirs=/QIBM/UserData/MyJava400

  5. Note: You may need to adjust the directory based on the current settings of java.ext.dirs. You can find the current settings by running the following from QSHELL.


    echo '!callmethod java.lang.System.getProperty(java.ext.dirs)' |  java -cp /qibm/proddata/http/public/jt400/lib/jt400.jar com.ibm.as400.access.jdbcClient.Main jdbc:db2:localhost

     Call returned /QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit/jre/lib/ext:/QIBM/UserData/Java400/ext

In my case, I would then set -Djava.extdirs=/QOpenSys/QIBM/ProdData/JavaVM/jdk50/32bit/jre/lib/ext:/QIBM/UserData/MyJava/ext

Upvotes: 1

James Allman
James Allman

Reputation: 41158

You can adjust the Java classpath.

Upvotes: 3

Related Questions