从 perl 调用 java 类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3100068/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 00:21:25  来源:igfitidea点击:

Call a java class from perl

javaperlcall

提问by Abhishek

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

我想从 perl 调用一个 java 类。我通常使用命令行中的 java 类来进行一些处理,例如:

java com.something.some

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

现在,我需要从 perl 脚本内部调用它。

Could you let me know how I can do it?

你能告诉我我该怎么做吗?

采纳答案by Andrzej Doyle

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

这很简单 - 您只需使用系统命令来执行任意命令行,例如

system("java com.something.Some")

回答by andcoz

The Javalibrarylets you to easily integrate Java calls in Perl code.

Java使您可以轻松地将 Java 调用集成到 Perl 代码中。

e.g.

例如

use Java;
$java = new Java;
$obj = $java->create_object("com.my.Class","constructor parameter");
$obj->myMethod("method parameter");
$obj->setId(5);

回答by daotoad

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

Inline::Java是一个众所周知的 Java/Perl 集成模块。它简化了在 Perl 代码中嵌入 Java 的过程以及反过来:将 Perl 嵌入到 Java 中。

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

查看 Cpan perldoc 以获取有关如何使用此模块的更多信息。