I try to get a PHP ScriptEngine from the ScriptEngineManager, but getEngineByName("php") returns null. The following unit test works, if I replace "php" with "javascript", but it fails for "php".
import static org.junit.Assert.*;
import org.junit.Test;
import javax.script.*;
public class ScriptEngineTest {
@Test
public void executeCommand() throws Exception {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("php");
assertNotNull(engine);
}
}
I must be missing something obvious. I know, that Rhino comes with Java 6 and is behind the javascript engine. Where do I get this for PHP?
EDIT:
I made my first step forward. On http://php-java-bridge.sourceforge.net/pjb/installation.php there is a download link for JavaBridgeTemplate5442.war. I unzipped this war file. Under WEB-INF/lib/ I found the jar files
- JavaBridge.jar
- php-script.jar
- php-servlet.jar
When I put JavaBridge.jar in my class path, the unit test works. (Probably I will also need php-script.jar to actually execute PHP code.)