What exactly are you trying to do?

At the most basic level a jar file is a zip archive, that happens to contain some java class files, metadata files, and other files needed by a java program, so if you just want to extract the contents of the jar file, or parse the metadata, then you should look on CPAN for modules that can parse zip archives. Archive::Zip::MemberRead looks a likey candidate.

If your jar file contains a complete java program that you need to run, then you can start it with a system, exec open or backticks call the same as any other external program. eg:

my $cmd = 'java -jar '.$jar_file_path.' '.join(' ',@args); system $cmd;

If your jar file is a library of some sort, that your want to access from perl, then you probably want something like Inline::Java as suggested by an Anonymous Monk further up this thread, before you do that, I think you should step back, and consider what you are actualy trying to do. Could you access what the Java library is accessing via a lower level API? If you have the source of the Java library, could you port the stuff you need to perl?


In reply to Re: Importing a jar file in a perl script by chrestomanci
in thread Importing a jar file in a perl script by kolursri

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.