Run Java From Django
I have the below code to run a java program from a file. import subprocess ccmd = ['javac', 'T.java'] process = subprocess.Popen(ccmd) process.wait() rcmd = ['java', 'T'] output =
Solution 1:
No, I don't think there is a way to run the code without saving it to the drive, since the Java compiler only takes files as input and produce files as output.
But you could rather simply save the file in a temporary directory, compile it, run it, and delete the two files (the posted .java file and compiled .class file). You can even delete these files while they're being executed.
But please note that executing arbitrary, user-submitted Java code is very dangerous.
Post a Comment for "Run Java From Django"