1. Johnny Cockrell
  2. PowerBuilder
  3. Thursday, 17 August 2017 22:18 PM UTC

Hello, not sure if anybody can help me with this but thought i'd try.  I have an application that was originally written in Powerbuilder versio 7.0  years ago and has been runningsince about 1999.  I converted it to Powerbuilder version 12.5 awhile back. The application uses an Oracle Database running on a Linux server. The application also currently calls a perl script running on the same server as the database. It calls the Perl script by calling a stored procedure on the database which then makes a system call and executes a shell script  which then executes the Perl script.

Now, I need to move everything to new server(s). The database will be on a dedicated linux based database server. The Perl script will be on a different Linux server. The Perl script has also been rewritten as a Java program/class. So, I have two options, continue to run the Perl or try to call the Java version from Powerbuilder.  To run the existing Perl it seems I will have to run it as a CGI script. To do this i'll need to run it from Powerbuilder by building a URL in Powerbuidler and calling it. My other option is to try and call the Java Class from Powerbuilder. 

First of all is either of these ways possible and if so which would be the easiest/best way to do it. Are there any other better alternatives? Running it as a CGI will be more complicated because it will involve installing Perl on the server. The Perl script is very large and so far i'm getting Perl errors when trying to run it manually due to missing perl modules etc.  I'm working with several things i'm not very familiar with on this app, the Perl and the Powerbuilder.

I'm thinking running it as a Java class will be better but I have no idea how to do something like this in Powerbuilder I'm not a Powerbuilder programmer and have only made minor changes in the past. If it's possible to call it as a Java class can someone please tell me how it's done. Would the  java class file need to be in the directory with the Powerbuilder executable and runtime files etc. etc.?

I'm not sure if any of this made sense but any help anyone can give me would be greatly appreciated.



Johnny Cockrell Accepted Answer Pending Moderation
  1. Thursday, 24 August 2017 16:09 PM UTC
  2. PowerBuilder
  3. # 1

Thanks for the help. I'll look over the replies and see what I can figure out. 

There are no comments made yet.
Alexander Strelkov Accepted Answer Pending Moderation
  1. Saturday, 19 August 2017 05:32 AM UTC
  2. PowerBuilder
  3. # 2

I've written a PBNI class for closely work PB & Java without javaproxy objects.

The next reference with real example explanation is from Russian forum


There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Friday, 18 August 2017 14:51 PM UTC
  2. PowerBuilder
  3. # 3

I have PowerBuilder code that run Java code using the RUN command.

1) Create a JAR file with the Java classes you need. The Java code should be stand-alone, meaning it has a main{} and a run{}.

2) In your PB code, you build the command string. In my case, there's an entire function devoted to doing this, then following up to see when the Java code completes processing. The RUN command line will look something like this. Note that I have four parameters in addition to the starting Class: UID, FILEUID, SS, and CONFIGFILE. Ensure that the java.exe you use is a match for the code used to compile the JAR file,

// OKnight, 15-FEB-2005.   Wrap all string parms in double-quotes.
// ----------------------------------------------------------------------------------------------
ls_cmd = ls_java_exe                                                   + &
            ' -Xmx' + String(ii_memory)  + 'm'                       + &
                ' -cp "' + ls_jar_file + '"'                                  + &
            ' -UID=' + String(ii_aur_source_uid) + &
                ' -FILEUID=' + String(ii_source_uid)                + &
                ' -SS=' + String(il_batch_size)                        + &
              ' -CONFIGFILE="'   + ls_config_file + '"'             + &
                ' "' + is_pathname + is_filename   + '"'

// Actually start the JAVA process....
li_ret = run (ls_cmd, Minimized!)
IF li_ret <= 0 THEN
    ls_txt = "The Java code did not run successfully."
   GOTO Exit_Function


3) This will create a CMD window in which the Java code will run. Now you need to know when the job has completed.

// OKnight, 24-OCT-2006.  Its possible that the Java processing will complete
//    before we get here, so check for that condition.

Sleep (2)
    val        = FindWindowW(0, ls_java_exe)        // The name of the EXE is the name of the CMD window
    lb_exists  = FileExists (ls_pathname)
    Sleep (0.5)
LOOP UNTIL(val = 0)


4) Another way to determine the end of processing is by having the Java code create a text file at the end of its processing, and using the TIMER even in the PB code to look for that file.

Good Luck,



There are no comments made yet.
Praveen Rajarao Accepted Answer Pending Moderation
  1. Friday, 18 August 2017 13:05 PM UTC
  2. PowerBuilder
  3. # 4

You can refer to the example in this link - http://www.rgagnon.com/pbdetails/pb-0224.html

If the class is defined in a package, then the class should be present in the directory of your pbl in a tree directory reflecting the package




There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Friday, 18 August 2017 06:22 AM UTC
  2. PowerBuilder
  3. # 5

I think both methods are possible.

Call a URL from powerbuilder is not tricky. Look in the help for "Inet" object.

If you prefer Java you could simply "run" the class if it's a program (it must contains a main method). Google for "run java class" and use Powerbuilders "run" method.

Another way is to use the Powerbuilder Native Interface (PBNI) to interact with Java. But this is more tricky.

There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.