Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call a java class from perl

Tags:

java

perl

call

I would like to call a java class from perl. I usually use the java class from command line to do some processing like:

java com.something.some

Now, I need to call it from inside a perl script.

Could you let me know how I can do it?

like image 315
Abhishek Avatar asked Jun 23 '10 08:06

Abhishek


3 Answers

The Java library lets you to easily integrate Java calls in Perl code.

e.g.

use Java;
$java = new Java;
$obj = $java->create_object("com.my.Class","constructor parameter");
$obj->myMethod("method parameter");
$obj->setId(5);
like image 164
andcoz Avatar answered Nov 15 '22 17:11

andcoz


This is simple enough - you just use the system command to execute an arbitrary command line, e.g.

system("java com.something.Some")
like image 33
Andrzej Doyle Avatar answered Nov 15 '22 18:11

Andrzej Doyle


Inline::Java is a well known module for Java/Perl integration. It simplifies embedding Java in Perl code as well as the converse: embedding Perl into Java.

View the Cpan perldoc for more information on how to use this module.

like image 36
daotoad Avatar answered Nov 15 '22 18:11

daotoad