This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Is there any way where you can pass values from java to the perl program? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is there any way where you can pass values from java to the perl program?" Watch "Is there any way where you can pass values from java to the perl program?" New topic
Author

Is there any way where you can pass values from java to the perl program?

john klucas
Greenhorn

Joined: Jul 31, 2001
Posts: 23
I have a stand alone application which take the inputs from the user. i have a perl program which works fine on its own.
But is there any way where i can take the inputs from that stand alone java application and pass the inputs to this perl program to do some processing?
Larry Anderson
Greenhorn

Joined: Aug 06, 2001
Posts: 26
If you wanted to make a machine-specific call you could use the Runtime.getRuntime().exec("appname " + arglist), in the middle of your program to reference an external application. Hope this helps,
Larry
john klucas
Greenhorn

Joined: Jul 31, 2001
Posts: 23
i am new to perl world, so can u please elaborate on that.
I am using Visual Age for java and Active Perl for windows platform.
Larry Anderson
Greenhorn

Joined: Aug 06, 2001
Posts: 26
Well that's your problem John, you're using VisualAge . Just kidding. Actually, I'm not sure exactly what kind of elaboration I can provide you, except to make sure that you reference your Perl program with the exec() call relative to that path that it is in, and make sure that the arguments that you append to the string match the arguments that you take in from the command-line with your Perl program. Maybe if I knew the kind of problem you were running into (specifically), I could help you better. Did you try the command above? Where is your java program and your perl program located? Let me know what you're running into. Hope I can help,
Larry
john klucas
Greenhorn

Joined: Jul 31, 2001
Posts: 23
I have mentioned the full path :
Runtime R = Runtime.getRuntime();

R.exec("d:\\ActivePerl\\bin\\perl rscdetail2.pl " + contract_number+" "+member_id+" "+start_date+" "+end_date);
I used Visual age Debugger and checked the value it generates from this -- "d:\\ActivePerl\\bin\\perl rscdetail2.pl "+ contract_number+" "+member_id+" "+start_date+" "+end_date
i guess its generating a correct path to look up for rscdetail2.pl but for some reason it's not understanding R.exec() ???
Does it have to do anything with Active perl for windows platform.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there any way where you can pass values from java to the perl program?
 
Similar Threads
Is there any way where you can pass values from java to the perl program?
Calling Struts from standalone Java application
"public static void main(String[] args)" rule?
How can you pass the arguments from the java program to the perl program?
Invoke Java from Perl