Forums

Running Java Code and Capturing its Output using Python

Hello~ I created a code editor in my Django project and when the user clicks run, the code is send to the backend and Python tries to compile and run it. However, on PythonAnywhere it returns the output javac: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory I captured the output by using subprocess.check_output('javac -d . *.java', shell=True) Is there any way I can run Java commands in the console on PythonAnywhere? I am willing to try out docker consoles. I am also willing to install a portable version of Java if that is possible on PythonAnywhere. Anyways, thank you so much!

To get a better idea of what I'm trying to create 1. jhihyangwu.pythonanywhere.com 2. HOST MATCHES 3. Username: B18P8VAED6, Password: Q69UY0L45N 4. Click on … and HOST 5. Open another tab and go to jhihyangwu.pythonanywhere.com 6. Fill in NAME and MATCH ID and press JOIN, START

First of all: That seems like a very bad idea. Allowing random visitors to your site to run code like that will mean that, they are running code as you on PythonAnywhere. They can do anything to your account that you can - create and delete files, run other processes, read and write to your databases. You may trust their intentions, but are you sure that they might not accidentally do something irrecoverable to your account?

I see that you've spoken to one of my colleagues over email and they've given you the ability to do it, but I would really advise against it.

Thank you so much, it works now!! I just disabled my web app and now I going to work on security by banning non-predefined import statements.