Results 1 to 8 of 8
  1. #1
    JavaEmpires is offline Member
    Join Date
    Dec 2007
    Posts
    19
    Rep Power
    0

    Default [B] How to call Perl script from Java [/B]

    Hi all,
    Can anyone tell me how to call Perl scripts in Java?
    I googled for a long time and came to know about JPL...what it is and how to use it? . Is there any alternative to JPL?
    In most of the tutorials I saw the perl scripts were embeded into java class. wat if the script written in another file to be used?

    Please try to guide me. Its urgent. If possible try to provide a working example.


    Thanks in advance.


  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    JavaEmpires is offline Member
    Join Date
    Dec 2007
    Posts
    19
    Rep Power
    0

    Default

    :-) I am not aware of perl at all so fell short of proper words....

    I wanted to ask, how to execute perl scripts and how to call perl modules from Java.... Hope i have used proper words :-)

    Actually I want to call perl modules as if they were java methods so that i can pass or return data types.

    When I googled I got something called as JPL and Inline::Java..
    JPL works on UNIX platforms but Inline::Java on windows as well... I tried to install Inline::Java but couldnt succeed.

    If you could help me to solve my problem I would be thankful to u. and its really urgent.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  5. #5
    JavaEmpires is offline Member
    Join Date
    Dec 2007
    Posts
    19
    Rep Power
    0

    Default

    the INSTALL file is says ,

    nmake
    nmake test
    nmake install

    nmake completes successfully.
    nmake test fails miserably
    nmake install gives following error:

    Java Code:
            nmake -f Makefile all -nologo
            dlltool --def JNI.def --output-exp dll.exp
            g++ -o ..\blib\arch\auto\Inline\Java\JNI\JNI.dll -Wl,--base-file -Wl,dll
    .base -mdll -L"D:\SoftwareInstallFolder\Perl5.10\lib\CORE" JNI.o -Wl,--image-bas
    e,0x2e220000  D:\SoftwareInstallFolder\Perl5.10\lib\CORE\perl510.lib D:\Software
    InstallFolder\Dev-Cpp\lib\libkernel32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\lib
    user32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libgdi32.a D:\SoftwareInstallFolde
    r\Dev-Cpp\lib\libwinspool.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libcomdlg32.a D
    :\SoftwareInstallFolder\Dev-Cpp\lib\libadvapi32.a D:\SoftwareInstallFolder\Dev-C
    pp\lib\libshell32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libole32.a D:\SoftwareI
    nstallFolder\Dev-Cpp\lib\liboleaut32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libn
    etapi32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libuuid.a D:\SoftwareInstallFolde
    r\Dev-Cpp\lib\libws2_32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libmpr.a D:\Softw
    areInstallFolder\Dev-Cpp\lib\libwinmm.a D:\SoftwareInstallFolder\Dev-Cpp\lib\lib
    version.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libodbc32.a D:\SoftwareInstallFol
    der\Dev-Cpp\lib\libodbccp32.a D:\SoftwareInstallFolder\Dev-Cpp\lib\libmsvcrt.a d
    ll.exp
    JNI.o(.text+0x9ef):JNI.c: undefined reference to `_imp__JNI_GetCreatedJavaVMs@12
    '
    JNI.o(.text+0xd66):JNI.c: undefined reference to `_imp__JNI_CreateJavaVM@12'
    collect2: ld returned 1 exit status
    NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code '0x1'
    Stop.
    NMAKE : fatal error U1077: 'C:\WINNT\system32\cmd.exe' : return code '0x2'
    Stop.
    I found that Inline::Java is only useful when you embed your perl code into java source file.

    In my case, there are already written perl scripts and i need to call modules from those scripts through java.

    Is there any way to do that?

    Thanks..

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  7. #7
    JavaEmpires is offline Member
    Join Date
    Dec 2007
    Posts
    19
    Rep Power
    0

    Default

    Initially i thought the same thing..
    But wat if the perl subroutine returns an array or other complex structure?
    and using Runtime.exec() we execute only the script file as a whole and not a single subroutine from the script file..

    I found another wrapper called EPerl [sourceforge.net/projects/eperl/] for windows.
    I installed it and tried a simple Java program to load the EPerl library.. and I got the UnSatisfiedlink Error. The EPerl.dll is in the java.libray.path as well.

    If you could please try executing java program using EPerl I would be thankful to you.

    Heres is a simple demo for Eperl...
    [codeproject.com/KB/library/EPerlQuickIntroduction.aspx]


    Please give it a try...

    Thanks

  8. #8
    wahmed is offline Member
    Join Date
    Dec 2008
    Location
    Ireland, Dublin
    Posts
    1
    Rep Power
    0

    Default

    calling the script can be done by Runtime.exec().

    But I believe you have to share data/arrays manually by writing to a common file or by sockets. I am not sure about Perl but works with .exe's written in C++.

    let us know if you give it a try.

    Thanks,

    Waqas

Similar Threads

  1. How to instantiate Class, into jsp, java script
    By silvia in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 01-04-2014, 08:08 AM
  2. Replies: 1
    Last Post: 01-07-2011, 07:20 AM
  3. logout using java script
    By pankajagar2001 in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 01-03-2008, 06:37 AM
  4. Use Perl function with java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 06:25 AM
  5. The lasted java script
    By silvia in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 05:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •