Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
ArjunKumar
Gerbil In Training
Topic Author
Posts: 6
Joined: Fri May 31, 2019 3:47 am

Passing Input Parameters In Java Program by PHP

Wed Mar 16, 2022 4:57 am

Hello All, I am new in Java programming and I'm creating a website that will allow user to Write and Execute java program online.

I've write code that compiles and execute java program online using PHP. Here is the code :

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

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/
 
meerkt
Gerbil Jedi
Posts: 1754
Joined: Sun Aug 25, 2013 2:55 am

Re: Passing Input Parameters In Java Program by PHP

Wed Mar 16, 2022 8:12 am

Not the best forum for these questions, probably. :)
It's both not progamming-focused, and very inactive.

With that said, just examine what's wrong with the string you're trying to parse:
https://stackoverflow.com/questions/187 ... own-source

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On