Search code examples
javaphpapachetomcatbridge

How to execute java functions/script in PHP


I have a system which is implemented using PHP(Joomla). Now the client wants to integrate a SMS gateway. Unfortunately SMS gateway does not supoort PHP. It's written in Java and All the examples are written in JAVA.

I'm supposed to include webservices‐rt.jar to my program and run a example script as below.

lk.mobitel.esms.User user = new lk.mobitel.esms.User (); user.setUsername(“TestUser”);
user.setPassword(“Password”);
lk.mobitel.esms.test.ServiceTest st = new lk.mobitel.esms.test.ServiceTest (); 
System.out.println(st.testService(u));

According to my knowledge I can run a .jar as below using PHP

<?php exec("java -jar filename.jar arguments",$output); ?>

How can I run a JAVA script like above in PHP? Is it possible? Is there a way to bridge PHP and JAVA? What I want is to run JAVA in PHP else I would say communicate between these two.


Solution

  • I never did this, but PHP Manual gave a link for PHP-Java Bridge for PHP5 as PHP/Java Bridge. If it is what you are looking for ?