s.nowinski has asked for the wisdom of the Perl Monks concerning the following question:

hey! i have a perl cgi script, and i wish to pass one value into a java program, have the program then do something and pass it back. i was wondering how i can go about this without using inline and where i need to keep the java program - if not in the cgi-bin? there are two java programs that i want to call in different if loops in perl. is that also possible? i would appreciate any help. thanks!

  • Comment on how to call java from perl without inline

Replies are listed 'Best First'.
Re: how to call java from perl without inline
by kennethk (Abbot) on May 14, 2012 at 14:35 UTC

    Why are you trying to avoid Inline::Java? Why do you need to call the Java programs, i.e. what do they do that can't be done in Perl? Why do you need to call Perl, i.e. why are you not just running Java services via Apache_Tomcat? Mixing techs is often a giant hassle, which is why folks coded up the Inline modules in the first place.

    Probably the easiest way to interface codes the require without Inline is via the command, exchanging data via some predetermined format like JSON. You can go as simple as backticks or use IPC::Open3 or perlipc if you need more power. I'd also suggest strongly you use Taint mode if you are exposing the command line to the outside world. I would not suggest trying to tackle XS on this on your own, as it will be a total mess. Which is why someone wrote Inline::Java....

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: how to call java from perl without inline
by Anonymous Monk on May 14, 2012 at 13:39 UTC
    It's probably possible. What have you tried? After reading the documentation, where are you stuck without the help of the monks? Show your code!