1

I am executing a Java class in PHP using PHP-Java Bridge following Official documentation. I have moved NewFile.jar in lib folder in web apps/WEB-INF folder of tomcat I am creating a file in java then calling that java class in PHP which will create a file in that particular location. Unable to create file, I don't know what is happening?

File 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: test.php

<?php 

require_once("http://localhost:8080/JavaBridge/java/Java.inc");
echo "Hello";
$data = new java("NewFile");

?>

This is what i getting in front-end

enter image description here

Is their problem in my setup or what can anyone help me out?

Thanks

7
  • This answer help you? Commented Dec 30, 2019 at 10:52
  • What have you tried and didn't work? please add source code of your specific problem Commented Dec 30, 2019 at 10:53
  • @akshaypatil if you tried the guide you linked, which is the problem? Commented Dec 30, 2019 at 10:57
  • "Official Documentation Didn't help me?" yet absolutely no description from you of what is going wrong. Commented Dec 30, 2019 at 10:58
  • Does this answer your question? Run Java class file from PHP script on a website Commented Dec 30, 2019 at 11:04

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.