johnklucas has asked for the wisdom of the Perl Monks concerning the following question:

I have a stand alone Java application which take the inputs from the user. Is there any way where i can take the inputs from that stand alone java application and pass those inputs to the perl program to do some processing?
  • Comment on how can you pass values from the objects in java to the perl program?

Replies are listed 'Best First'.
Re: how can you pass values from the objects in java to the perl program?
by traveler (Parson) on Aug 14, 2001 at 20:09 UTC
    Sure, but only if your program is standalone (or possibly if you fiddle the browser security settings). Use Exec to start the Perl process, passing the info on the command line. If the Perl process does all the remaining processing, you can use execPrint or just let the process run (after, say, exec) and print output.

    If you need to communicate with the new process, it would probably be best to open a TCP connection to the Perl child. You might be able to use a Java pipe, but I do not know if it can be used across languages.

    HTH, --traveler

      Thnx for ur reply. I am still havimng some problem. I have done as shown below: I am passing those values to a string Object like this-- contract_number = ivjTextField2 .getText();
      member_id = ivjTextField3.getText();
      start_date = ivjTextField4.getText();
      end_date = ivjTextField5.getText();
      and then, Runtime R = Runtime.getRuntime();
      R.exec("d:\\ActivePerl\\bin\\perl rscdetail2.pl " + contract_number+" "+member_id+" "+start_date+" "+end_date);
      but it's not doing any thing. Can u please help on this. Thanx in advance!! PS: i am using Active Perl for Windows Platform and visual Age for Java.
        Where is rscdetail2.pl located?
        Try specifying the full path to it.
(elbie): how can you pass values from the objects in java to the perl program?
by elbie (Curate) on Aug 14, 2001 at 22:20 UTC
    Depending on how you give those inputs to your java app, there might be another way. I realize that you said your app was standalone, but in the spirit of TMTOWTDI...

    If you're calling an applet, and passing the parameters via the param tag, you could just pass the parameters to perl first and have perl spit out the html tags for you java applet afterwards.

    elbieelbieelbie

      I have a standalone java application which takes the user inputs. I am passing those values to a string Object like this-- contract_number = ivjTextField2 .getText(); member_id = ivjTextField3.getText(); start_date = ivjTextField4.getText(); end_date = ivjTextField5.getText(); and then, Runtime R = Runtime.getRuntime(); R.exec("d:\\ActivePerl\\bin\\perl rscdetail2.pl " + contract_number+" "+member_id+" "+start_date+" "+end_date); but it's not doing any thing. Thanx in advance!! PS: i am using Active Perl for Windows Platform and visual Age for Java.