The tool to call perl from java would be JNI(Java Native Interface). Which is a rather rich API provided by Sun. The definative reference/tutorial is Java Native Interface.

It can be tricky, but it can be done.

HOWEVER Given that you've implied that most of the need to call perl from java lies in Perl regexe's you should be aware that as of Java 1.4.1, Java includes a 'Pattern' class whose syntax closely parallels the Perl regex syntax with some differences(ref Pattern Docs)

It pains me to recommend this, but you would probably do well to examine how hard it would be to convert your existing perl regexes to Java Patterns if Java 1.4.1 is in use. If the patterns are relatively simple and you get the hang of Java patterns quickly enough, then you should probably go with converting your perl regexes to Java Patterns. Two days of kicking the tires on trying Java patterns to see if it would work would probably be time very well spent. If you're using regex syntaxes that are not well supported in Java patterns, look again at the JNI solution.

Also consider that if you move to a different platform, you're going to have to make sure that your JNI library works on that other platform as well.

Keep also in mind the people who follow you on this project. If you manage to keep it all Java, you've simplified their lives considerably. If you go the JNI route, they'll have to support Java, Perl, C/C++, Makefiles and JNI's own collection of issues.

Step back, and examine the pros and cons of both approaches very carefully.


In reply to Re: Calling perl from java by ptkdb
in thread Calling perl from java by fletcher_the_dog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.