I've write code that compiles and execute java program online using PHP. Here is the code :
Code: Select all
<html>
<head>
<title>php java demo</title>
</head>
<body>
<?php
exec("jdk\\bin\\javac demo.java 2>&1", $output);
print_r($output);
exec("jdk\\bin\\java -Xmx512M -Xms64M demo 2>&1" , $output1);
print_r($output1);
?>
</body>
this code works perfect. but when I've to give input to program using BufferedReader or other schemes, this method fails.
Code: Select all
Enter a number Exception in thread "main" java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at demo.main(demo.java:7)
for example I am trying to make that STDIN input box at the bottom of
https://www.interviewbit.com/online-java-compiler/