?
Solved

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

Posted on 2011-09-13
9
Medium Priority
?
341 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:Tolgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36530907
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
 

Author Comment

by:Tolgar
ID: 36531118
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
 
LVL 28

Accepted Solution

by:
FishMonger earned 2000 total points
ID: 36531384
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 47

Expert Comment

by:for_yan
ID: 36531501
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
 
LVL 9

Expert Comment

by:parparov
ID: 36531586
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
 

Author Comment

by:Tolgar
ID: 36538153
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
 

Author Comment

by:Tolgar
ID: 36538172
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
 
LVL 9

Expert Comment

by:parparov
ID: 36538621
Use FishMonger's example. He only called your @args differently.
0
 

Author Comment

by:Tolgar
ID: 36538681
oh. perfect. I missed it.

Thanks,
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question