Note that there are some explanatory texts on larger screens.

plurals
  1. POtomcat java php
    primarykey
    data
    text
    <p>I want to use tomcat tomcat, java &amp; php altogether. my java program creates a text file and write something on the file, when I run that not file is getting created. java program is running through command line. I am keeping all files in /usr/local/tomcat/webapps/testjava. Content of Java File: </p> <pre><code>public class test { public static void main(String args[]) throws IOException { try{ Writer fos = null; File outputFile = new File("outList.txt"); fos = new BufferedWriter(new FileWriter(outputFile)); fos.write("hi"); fos.write("\n"); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre> <p>Content of PHP file:</p> <pre><code>&lt;?php $output = exec("java test", $ret); echo $ret; echo file_get_contents("outList.txt"); echo "HI"; ?&gt; </code></pre> <p>$ret given output as Array. HI is getting displayed. </p> <p>One More Thing when I do php index.php on command line it is working, mean outList.txt is getting created. </p> <p>var_dump($ret) is giving : </p> <pre><code>HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: java.lang.RuntimeException: PHP Parse error: syntax error, unexpected T_ECHO in /usr/local/tomcat/webapps/testjava/index.php on line 7 php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:499) php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:521) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) root cause java.lang.RuntimeException: PHP Parse error: syntax error, unexpected T_ECHO in /usr/local/tomcat/webapps/testjava/index.php on line 7 php.java.servlet.fastcgi.FastCGIServlet.parseBody(FastCGIServlet.java:409) php.java.servlet.fastcgi.FastCGIServlet.execute(FastCGIServlet.java:433) php.java.servlet.fastcgi.FastCGIServlet.handle(FastCGIServlet.java:481) php.java.servlet.fastcgi.FastCGIServlet.doGet(FastCGIServlet.java:521) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:722) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.12 logs. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload