如何从PHP调用自定义Java方法? [英] How to call custom java methods from PHP?

查看:128
本文介绍了如何从PHP调用自定义Java方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是PHP和Java的新手.目前,我正在一个项目中,该项目在PHP代码中调用java类及其方法.我正在为此创建概念证明.问题是我无法连接在Java中创建的自定义类.可以说我不知道​​该怎么做.我已经使用java.inc和javabridge.jar文件连接到系统类,但是无法连接到简单类.我遵循的步骤是:

创建了一个名为clsForPHP的java包,它具有一个sum()方法,该方法带有2个参数并返回整数值. (这是使用MyEclipse IDE创建的)现在,我尝试从PHP调用此函数.我已将包含软件包的jar文件复制到PHP项目. (Eclipse- Helios是IDE)

I am new to both PHP and Java. Currently I am working on a project which call java class and its methods in the PHP code. I am creating a proof of concept for this. The problem is I am not able to connect custom class I have created in java. More over it could be said I don''t know how to do it. I have used java.inc and javabridge.jar files to connect to the system classes but not able to connect to a simple class. The step I have followed is:

Created a java package, class called clsForPHP and it has a method sum() which takes 2 parameters and returns integer value. (This is created using MyEclipse IDE) Now I am trying to call this function from PHP. I have copied the jar file containg the package to PHP project. (Eclipse- Helios is the IDE)

$d= new java("clsForPHP.class");



请帮忙!!我进行了很多搜索,但找不到合适的解决方案.我认为应该将此程序包添加到java.inc文件中,但我不知道该怎么做.我在使用Win7作为操作系统且用于POC的本地系统中进行设置.



Please help!! I have searched a lot but couldn''t able to find a proper solution. What I think is this package should be added in the java.inc file but I don''t know how to do it. I am setting this in my local system which uses Win7 as OS and this for POC purpose.

推荐答案

d = new java(" );
d= new java("clsForPHP.class");



请帮忙!!我进行了很多搜索,但找不到合适的解决方案.我认为应该将此程序包添加到java.inc文件中,但我不知道该怎么做.我在使用Win7作为操作系统以及POC目的的本地系统中进行设置.



Please help!! I have searched a lot but couldn''t able to find a proper solution. What I think is this package should be added in the java.inc file but I don''t know how to do it. I am setting this in my local system which uses Win7 as OS and this for POC purpose.


请参阅链接


这篇关于如何从PHP调用自定义Java方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆