How to instantiate/call java class with parameter from PHP?

こ雲淡風輕ζ 提交于 2019-12-23 03:22:24

问题


For example, i have java class JRXlsExporter, if i instantiated that java from java my code is :

    JRXlsExporter myObject= new JRXlsExporter();

and from PHP become:

    $myObject = new Java("net.sf.jasperreports.engine.export.JRXlsExporter");

It works, but if i have java class with parameter, for example :

    JRXlsExporter myObject= new JRXlsExporter(param1,param2);

How to instantiate/call that java class from PHP ?


回答1:


Here is an example of how java.util.Date object is instantiated, with some constructor arguments:

$date = new Java("java.util.Date", 70, 9, 4);

Further, it says:

The new Java("java.util.Date", 70, 9, 4) call creates a new instance of the java.util.Date class using the java.util.Date(int year, int month, int day) constructor.

So, you could maybe try this:

$myObject = new Java("net.sf.jasperreports.engine.export.JRXlsExporter", param1, param2);


来源:https://stackoverflow.com/questions/13247418/how-to-instantiate-call-java-class-with-parameter-from-php

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