Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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)
PHP
$d= new java("clsForPHP.class");


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.
Posted
Updated 26-Apr-12 23:08pm
v2

1 solution

Refer to this link
 
Share this answer
 
Comments
idds24 27-Apr-12 3:05am    
Well, I have tried that. however, not able to invoke my custom class.
Loke.mysore 27-Apr-12 3:17am    
I think u had to remove .class and then try.
idds24 27-Apr-12 3:40am    
I tried removing .class and the same error "java.lang.ClassNotFoundException".
While debugging, it is going inside java.inc file where the java() function is present and returns with class not found exception. The clsForPHP.class, java.inc and javabridge.jar are in same folder.
Loke.mysore 27-Apr-12 4:23am    
There must be some problem with the path, That's it i can tell.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900