Reputation: 13
I am calling a java class from PHP program using Php-Java Bridge and I am using the Tomcat server.
Where I have created a Jar file of my java program and put it in C:\Tomcat 8.5\webapps\JavaBridge\WEB-INF\lib
this folder and my small PHP script which call java program resides in C:\Tomcat 8.5\webapps\test
folder
My jar file name and java class name is same.
File Name: NewFIle.java
import java.io.File;
import java.io.IOException;
public class NewFile {
public static void main(String[] args) {
try {
File file = new File("E:/myfile");
if(file.createNewFile())System.out.println("Success!");
else System.out.println ("Error, file already exists.");
}
catch(IOException ioe) {
ioe.printStackTrace();
}
}
}
File Name: test.php
<?php
require_once("java/Java.inc");
// echo java("java.lang.System")->getProperties();
echo java("NewFile");
echo "Hello";
// print_r($data);
?>
I am getting an empty output problem to seem where I am calling java program, the java program which I wrote is creating a normal file in a particular file location.
Please Let me know what i am doing wrong any suggestion will be accepted. I know about PHP exec command but I am not able to execute with PHP-JAVA bridge
Steps screenshots from installation guide and user guide..
Second Screenshot
Upvotes: 1
Views: 561