Call a java class from perl

Abhishek picture Abhishek · Jun 23, 2010 · Viewed 12k times · Source

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?

Answer

andcoz picture andcoz · Jun 23, 2010

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);