Attempting to inline Java into Perl via the Inline::Java module

前端 未结 2 1012
星月不相逢
星月不相逢 2021-01-25 12:39

This is my first attempt to inline Java code in Perl. We cannot use the standard SFTP command on our system. This is out of my power. We have a jarfile called SFTP.jar which can

2条回答
  •  隐瞒了意图╮
    2021-01-25 13:25

    Okay. I figured it out. I had several things wrong:

    • Under Study, I had both the Methods and Class, but I only should have the Class.

    Wrong

    use Inline (
        Java => 'DATA',
        J2SDK => $ENV{JAVA_HOME},
        CLASSPATH => $PERL_CLASSPATH,
        STUDY => ["SFTP", "close", "list", "get", "put", "remove"],
    #    DEBUG => 4,
    );
    

    Right

    use Inline (
        Java => 'DATA',
        J2SDK => $ENV{JAVA_HOME},
        CLASSPATH => $PERL_CLASSPATH,
        STUDY => ["SFTP"],
    #    DEBUG => 4,
    );
    
    • When I declare the SFTP object as new, I have to give it the full Perl namespace:

    Wrong

    eval {$self->{CONNECTION} = new SFTP($server, $user, $password);};
    

    Right

    eval {$self->{CONNECTION} = new FMS3::Sftp::SFTP($server, $user, $password);};
    

    You spend several hours on something like this, give up, and then suddenly the light in the ol' dusty attic comes on. I'm a fairly smart guy. Stick a screwdriver in a live socket, and after the third or fourth time, I go "Hey, maybe that's not a good idea".

提交回复
热议问题