0

I'm making an application where people can upload a java code and do stuff with it.

The application i'm making is in Python. I was wondering whether it was possible to call the 'javac' command from within python, in order to compile the uploaded java file

I'm also using JPype

1
  • So, where is your problem? Please post (as an edit to the question) what you are doing, and what the result (error messages and such) is. Commented Aug 10, 2011 at 19:21

2 Answers 2

4

http://docs.python.org/library/subprocess.html

But are you sure that allowing people to submit arbitrary code is a good idea? There are security aspects of that to consider...

Sign up to request clarification or add additional context in comments.

4 Comments

The program runs on their own computer. So there's no risk in it for me
And that computer has network access? So someone can upload a java program that is an open proxy, or a web server that serves illegal content, or..
@Erik: I suppose this is a kind of applet, which will run on the client's computer (= the same one which uploaded the code). There is no new danger here - if someone bad can upload from a client, he already can execute stuff there.
Could i have a little bit of help? I don't immediately have an idea on how to use classpaths etc to get java working
0

Entirely possible: just use the system command and invoke the java compiler. You'll probably need to set class paths and things of that nature, but it should work fine.

EDIT: see http://docs.python.org/library/os.html#os.system and http://docs.python.org/library/subprocess.html#module-subprocess for detail on invoking sub processes. You'll probably want to capture the output to return to the user in the event of a compile error.

1 Comment

subprocess.call is vastly superior to os.system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.