简体   繁体   English

从Perl脚本调用Java方法和类

[英]Calling Java methods and classes from Perl script

I have a quite huge Java class that has several imported packages and libraries (related to natural language processing). 我有一个很大的Java类,其中包含几个导入的包和库(与自然语言处理有关)。 I want to call some specific methods of my Java classes and get results back using a Perl script. 我想调用Java类的某些特定方法,并使用Perl脚本获取结果。 How should I do this? 我应该怎么做? I guess the Inline::Java is not suitable for my purpose since the Java code is quite large to be incorporated at one place. 我猜Inline :: Java不适合我的目的,因为Java代码很大,可以在一个地方合并。

Why is Inline::Java not suitable? 为什么Inline :: Java不适合? You don't need to provide access to all the bits of your Java API. 您不需要提供对Java API所有位的访问。 You can write short methods that call into your Java stuff. 您可以编写调用Java内容的简短方法。 A small Java adapter layer can show up in your Perl code to give you the access you need. 一个小的Java适配器层可以显示在您的Perl代码中,从而为您提供所需的访问权限。 Have you tried it yet? 你尝试过了吗?

How big is this Java code base? 这个Java代码库有多大? I've been on projects that easily integrated big Java SDKs (although I wasn't that one doing that part). 我参与的项目可以轻松集成大型Java SDK(尽管我不是那个人在做那部分)。

I had ran into similar situation lately. 我最近也遇到过类似情况。 The best solution which worked for me was to use apache thrift service and expose the required methods through it. 对我最有效的解决方案是使用apache节俭服务并通过它公开所需的方法。 These method were then in turn consumed by the client written in perl. 然后,这些方法又由用perl编写的客户端使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM