I need help in executing perl script from java in linux

Joined
Feb 25, 2008
Messages
1
Reaction score
0
Hi all,
I am using the following java code to invoke a perl script named helloworld.pl. When i run the perl script individually, it displays "Hello world" on the console, but it is unable to produce the same o/p when called from java. It does nothing and no o/p is displayed. I dont know what im doing wrong.

---------- Java code -------------
import java.io.IOException;
class Test
{
public static void main (String [] args)
{
try {
String cmdString
= "perl /home/admin/helloworld.pl";
Runtime.getRuntime().exec(cmdString);
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
------------------------------------------------------------------------
-------------------- Perl Code -----------------
#!/usr/bin/perl -I/usr/local/lib/site_perl

print "hello world";
-------------------------------------------------------------------------

Please help me guys.....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top