Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help: Executing perl script from java

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help: Executing perl script from java

    Hi,

    Im trying to execute a perl script with parameters from my java code. given below is the first few lines.

     try
                {
                p = Runtime.getRuntime().exec("perl E:\\tools\\Rouge1551\\ROUGE-1.5.5.pl -n 4 -w 1.2 -m -2 4 -u -c 95 -r 1000 -f A -p 0.5 -t 0 -a E:/tools/Rouge1551/rougejk_A1.in");
     
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                String line="";
     
                while ((line = input.readLine()) != null) {
                                System.out.println(line);
               }              
               p.waitFor();
               }
                catch(Exception e)
                {
                    System.out.println("Exception: "+ e.toString());
                }
                finally {
                            if (p != null) {
                            close(p.getInputStream());
                            close(p.getErrorStream());
                            close(p.getOutputStream());
                            p.destroy();}
                        }

    The program does not print anything, since p.getInputStream returns null. The command works when i run in command prompt.
    please help.

    thanks
    jessie


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help: Executing perl script from java

    Try using a String array vs a String in the exec() method.
    Also read and print the error stream to see if there are any error messages.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help: Executing perl script from java

    thanks a lot. it was not working because there were some warnings. i corrected it and it works.!
    great.!

Similar Threads

  1. Exit Status from Perl program called by java using runtime
    By twk in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 2nd, 2011, 02:19 PM
  2. Executing query from java program
    By ashu000 in forum JDBC & Databases
    Replies: 1
    Last Post: June 25th, 2011, 12:43 PM
  3. Help Executing C Program From Java! (Ubuntu)
    By penguinGirl in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 18th, 2010, 01:47 PM
  4. Executing Linux Commands with Java GUI
    By linuxrockers in forum AWT / Java Swing
    Replies: 2
    Last Post: February 15th, 2010, 10:57 PM
  5. Problem with a waitFor() executing a script
    By Baldurian in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 29th, 2010, 10:45 AM