Search code examples
weblogicjythonwlst

Invoking Jython without Weblogic's WLST


I'm using an AIX machine which has Weblogic 9.21 installed and it also has jython as part of its installation (WLST).

Is there a way to run jython code without having to initialize the WLST first?

I have the following jars too if they bring in any ideas:

['.', '/opt/weblogic921/weblogic92/common/lib/jython.jar', '/opt/weblogic921/weblogic92/common/lib/config.jar', '/opt/weblogic921/weblogic92/common/lib/config.jar', '/opt/weblogic921/weblogic92/server/lib/weblogic.jar', '/opt/weblogic921/weblogic92/common/wlst/modules/jython-modules.jar/Lib', '/opt/weblogic921/weblogic92/common/wlst', '/opt/weblogic921/weblogic92/common/wlst/lib', '/opt/weblogic921/weblogic92/common/wlst/modules']

Right now I'm invoking the jython code using:

java -cp /opt/weblogic921/weblogic92/server/lib/weblogic.jar weblogic.WLST file.py

Solution

  • Paste below code in a shell script say jythonExec.sh and use it

    Example Usage : /bin/bash jythonExec.sh file.py

    #!/bin/bash 
    jythonJarLoc=/opt/weblogic921/weblogic92/common/lib/jython.jar
    javaLoc=/usr/bin/java
    pythonCacheDir=/tmp/pythonCacheDir
    if [ ! -f ${jythonJarLoc} ]; then
        jythonJarLoc=/opt/weblogic921/weblogic92/server/lib/weblogic.jar
    fi
    ${javaLoc} -cp ${jythonJarLoc} -Dpython.cachedir=${pythonCacheDir} org.python.util.jython $@