Call a java class from perl

不想你离开。 提交于 2019-12-12 08:24:26

问题


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?


回答1:


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

system("java com.something.Some")



回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/3100068/call-a-java-class-from-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!