#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    4
    Rep Power
    0

    Call Java jar from Perl script


    I would like to know the syntax to execute the Java jar from Perl script.

    It is a command line argument.

    Can you pls let me know how to call the Java.

    Thanks in advance.
  2. #2
  3. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    system, exec or qx()
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    4
    Rep Power
    0

    How to call java jar from Perl


    Originally Posted by Axweildr
    system, exec or qx()
    Hi Axweildr,
    I am new for Perl, could you tell me the exact code to use it.

    If I run the command from windows would be

    java -jar sample.jar arguments1 arguments2
  6. #4
  7. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    perl Code:
    @results=qx("/path/to/java -jar /path/to/sample.jar arguments1 arguments2");
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    4
    Rep Power
    0
    Originally Posted by Axweildr
    perl Code:
    @results=qx("/path/to/java -jar /path/to/sample.jar arguments1 arguments2");
    Hi Axweildr,
    Thanks Axweildr for your helping....

    I have developed standalone java application, and I am using third party application, It is supporting Perl script, It has option to run the perl script, I need to execute my Java from here.

    below is my whole code as suggessted by you

    @results=qx("D:\Program Files\Java\jdk1.5.0_06\bin\ java -jar C:\test\sample.jar one two three");

    I am getting this error

    'results' is not recognized as an internal or external command

    and the command is not executing.

    Pls help me out.

    Regards
    Ashok
  10. #6
  11. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    it has to be in a perl script
    perl Code:
    #!/usr/bin/perl
     
    @results=qx("D:/Program Files/Java/jdk1.5.0_06/bin/java -jar C:/test/sample.jar one two three");
    # note no space between path and java
    foreach (@results) { print; }


    and call by running the perl script
    Code:
    perl myscript.pl
    WoW ; \char inside double quotes is escaping the char, to stop interpolation, use forward slashes for paths, or use single quotes (though that will stop variable interpolation as well)

    HTH
    Last edited by Axweildr; September 19th, 2007 at 05:45 AM.
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2007
    Posts
    4
    Rep Power
    0
    I used the same code, but I m getting this error message

    "The filename,directory name, or volume label syntax is incorrect"

    Please help me out.


    Thanks
    Ashok
  14. #8
  15. 'fie' on me, allege-dly
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2003
    Location
    in da kitchen ...
    Posts
    12,894
    Rep Power
    6444
    is that an error from the perl or the java?
    --Ax
    without exception, there is no rule ...
    Handmade Irish Jewellery
    Targeted Advertising Cookie Optout (TACO) extension for Firefox
    The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones


    09 F9 11 02
    9D 74 E3 5B
    D8 41 56 C5
    63 56 88 C0
    Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
    -- Jamie Zawinski
    Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
    BIT COINS ANYONE

IMN logo majestic logo threadwatch logo seochat tools logo