Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I was wondering if it is possible to run a php file in a japenel or jlabel? for exampleI have a php file which shows a image that is 3d and the user and move it around to see it in 3d better, so yeh, is it possible to run a php file in a jpanel or jlabel or an emlemt of the sort?
Posted

The solution to this problem is to download the files JavaBridge.jar, php-script.jar and php-servlet.jar from HERE then import them into your class:

import javax.script.*;

import php.java.bridge.*;
import php.java.script.*;
import php.java.servlet.*;

String code="echo 5+5;"; //sample bit of php code
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByExtension("php");
try {
    engine.eval(code);
} catch (ScriptException ex) {
    //catch statement
}
 
Share this answer
 
v2
 
Share this answer
 
Comments
Sarin VT 24-Jul-13 6:20am    
This solution deals with running a php script which resides at server right?? kind of invoking.
I think the problem is to run a php file on client side java program( the php file also reside in the client machine )

Please correct me if am wrong.

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

  Print Answers RSS


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