tags:

views:

96

answers:

3

Hi folks,

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

and now, I need to call it from inside a perl script. Could you let me know how I can do it?

Thanks,J

+4  A: 

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

system("java com.something.Some")
Andrzej Doyle
+9  A: 

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);
andcoz
Interesting... the integration there is quite impressive. This is probably overkill for the task in the question, but the ability to interact with Java codebases at a deeper level than just `main` methods is intriguing.
Andrzej Doyle
+3  A: 

Iniline::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.

daotoad