Websydian v6.1 online documentationOnline documentation - Websydian v6.5

How do I run a Plex generated Java function on Windows

From experience we have found that running Plex generated Java programs on Windows often result in an incorrect class path. On top of that you will also need to check the Plex documentation on how to call the Plex function in the first place.

This document gives you an approach that eliminates the problems with class path being misspelled and it is also easy to add additional jar files to the class path. On top of that you can easily adjust the code to call different Plex generated Java programs.

Do the following:

  1. Create a directory for holding the application
  2. Create a subdirectory called jars
  3. Create a subdirectory called logs
  4. Copy the required jar files to the jars directory
  5. Copy the obclient.properties supplied by Plex to the directory specified in step 1.
    Make sure that you setup your oblicent.properties file correctly. Check with the Plex documentation for information.

    For Plex v6.1 the obclient.properties file is located in My Documents\CA\Plex\6.1\ObJava

  6. Run notepad and add the information below and save it as run.cmd in the directory specified in step 1.
@echo off
setlocal ENABLEDELAYEDEXPANSION
 
set JAVA_HOME=location_of_your_jvm
set PLEX_FUNCTION=package_and_name_of_the_function_to_call
 
set HOME_DIR=%~dp0
set JARS_DIR=.\jars
set LOGS_DIR=.\logs
 
pushd %HOME_DIR%
 
if "%JAVA_HOME%"=="" goto error
if "%PLEX_FUNCTION%"=="" goto error
 
rem ---------- Setup Classpath (BEGIN)
set CLASSPATH=
dir /B "%JARS_DIR%\*.jar" >%JARS_DIR%\dir.lst
for /F "delims=," %%i IN (%JARS_DIR%\dir.lst) do set CLASSPATH=!CLASSPATH!%JARS_DIR%\%%i;
if exist "%JARS_DIR%\dir.lst" del "%JARS_DIR%\dir.lst"
rem ---------- Setup Classpath (END)
 
rem ---------- Run Plex java program
echo Running Plex Java program - %PLEX_FUNCTION%
rem echo Using the classpath - %CLASSPATH%
"%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" ObRun.ObPanel.ObLaunch %PLEX_FUNCTION% Path="." Default >>%LOGS_DIR%\stdout.txt 2>>%LOGS_DIR%\stderr.txt
 
goto end
 
:error
echo Make sure that you set the JAVA_HOME environment variable
echo Make sure that you set the PLEX_FUNCTION to be called
pause
goto end
 
:end
popd
endlocal

By running the run.cmd you are now able to execute the Plex generated Java program.

Feel free to rename the run.cmd to accommodate your needs

Adding parameters to the call

In order to add parameters to the function being called, that is if you added any input fields to the Plex function.

Add the parameters to the following line by adding a comma separated list of values right after the Path="." e.g.

rem ---------- Run Plex java program
echo Running Plex Java program - 
"%JAVA_HOME%\bin\java" -cp "%CLASSPATH%" ObRun.ObPanel.ObLaunch %PLEX_FUNCTION% Path="." "StrParm1",NumParm2 Default >>%LOGS_DIR%\stdout.txt 2>>%LOGS_DIR%\stderr.txt 

Make sure that you enclose parameters of string that include spaces with "

Considerations