How to call a Java code within Perl code if the passing variables are too long?

Hi,
I have a Perl code and I will call my java code within this code.

The problem is; the values that I want to pass to the java code is too long that it is risky to pass them as below:

my $javaCmd = "java -jar $mydir/myTool/".
			 "Tool.jar $login '$List' $id $folder ".
			  "$option1 $option2 $soapEndpointURL";

system($javaCmd);

Open in new window



I heard that I can pipe, but I don't know how to do it?

Can you please let me know how I can do it?
TolgarAsked:
Who is Participating?
 
FishMongerConnect With a Mentor Commented:
Try the list form of system.

my @javaCmd = ('java', '-jar', "$mydir/myTool/Tool.jar", $login, $List, $id, $folder, $option1, $option2,  $soapEndpointURL);

system( @javaCmd );

Open in new window

0
 
for_yanCommented:
So do you want read the output of your perl program in the subsequent run of the java program?

and you can modify the ocde of both of them - correct?
0
 
TolgarAuthor Commented:
Yes I can modify the both of the code.

The thing that I want is exactly the way I explained in the initial question.

Call java code within perl. this is what I want.

This is the beginning of my java code:

public static void main(java.lang.String args[])

Open in new window


0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
for_yanCommented:
I think number of paraeters for java program is unlimited, so you should not be worrying
If you are concerned with having too many parameters especially if some of those are multiline text ,
perhaps one iption will be to communicate through the file - that probably would be most stright forward
0
 
parparovCommented:
If you want to embed Java code in Perl you can use Inline::Java module, but it's not a trivial thing.

http://search.cpan.org/dist/Inline-Java/Java.pod
0
 
TolgarAuthor Commented:
Actually, I found out what I need  to do. I need to pass all the arguments using @args just like in C.

so it will be something like:

system @args

Open in new window


But I need a concrete example how I can use it, preferably with some descriptive comments.

Thanks,

0
 
TolgarAuthor Commented:
Note: This will help me not to invoke any shells so I don't need to worry about multi line arguments in the system command.

Thanks,
0
 
parparovCommented:
Use FishMonger's example. He only called your @args differently.
0
 
TolgarAuthor Commented:
oh. perfect. I missed it.

Thanks,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.