1

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..

enter image description here

Second Screenshot

enter image description here

2
  • Are you sure you want to include the result of http://localhost:8080/JavaBridge/java/Java.inc? Shouldn't it be just java/Java.inc as written on php-java-bridge.sourceforge.net/pjb/tomcat6.php? Which steps of php-java-bridge.sourceforge.net/pjb/installation.php have you completed? Please edit your question to include the results of each step listed in the installation and PHP guide of PHP-Java bridge. Commented Dec 31, 2019 at 15:29
  • Yes sir, I have completed each and every step that listed in the installation, let me edit the question @Progman Commented Jan 2, 2020 at 4:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.