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

I'm working with Inline::Java for the first time to access an api another department wrote... I am doing OK with the actual code (it seems) but I am using the STUDY functionality which works... but in the Java you do something like...
import com.ftid.fisi.methodology.irs.evaluator.IrsHeader; # and use new IrsHeader();
whereas in the Perl I have
use Inline ( Java => 'STUDY', AUTOSTUDY => 1, STUDY => ['com.ftid.fisi.methodology.irs.evaluator.IrsHeader'], ); #and have to do new com::ftid::fisi::methodology::irs::evaluator::IrsHeader();
is there a better way to do this? Or a way to shorten up the namespace at least?

                - Ant
                - Some of my best work - (1 2 3)

Replies are listed 'Best First'.
Re: Shortcutting namespaces in Inline::Java
by TimToady (Parson) on Apr 24, 2007 at 18:31 UTC
    Well, the class name is just a string, but you can't use indirect object syntax with an indirect class name, so you'd have to use the arrow notation instead:
    use constant IrsHeader => "com::ftid::fisi::methodology::irs::evaluato +r::IrsHeader"; IrsHeader->new();
    Hope this helps.
      Heh... it works, though it gives me a not-so-fresh feeling... hrm...

                      - Ant
                      - Some of my best work - (1 2 3)

Re: Shortcutting namespaces in Inline::Java
by Moron (Curate) on Apr 24, 2007 at 18:02 UTC
    The documentation shows how to import java class files as Perl classes, so that you then only have to do:
    my $irsHeader = new IrsHeader();
    __________________________________________________________________________________

    ^M Free your mind!

      That's not quite the same (at least I don't think it is)... I am importing jar files using study, not writing Java code inline, and I don't control the jar files.

                      - Ant
                      - Some of my best work - (1 2 3)

        Whether using the studying features or not, you still have to import the .jar files to be able to use the shorter Perl syntax -- there is an example of that in the documentation I already linked under the studying section.
        __________________________________________________________________________________

        ^M Free your mind!