Note that there are some explanatory texts on larger screens.

plurals
  1. POCompiling and Executing Java file in python
    primarykey
    data
    text
    <p>how can I open an java file in python?, i've search over the net and found this:</p> <pre><code>import os.path, subprocess from subprocess import STDOUT, PIPE def compile_java (java_file): subprocess.check_call(['javac', java_file]) def execute_java (java_file): cmd=['java', java_file] proc=subprocess.Popen(cmd, stdout = PIPE, stderr = STDOUT) input = subprocess.Popen(cmd, stdin = PIPE) print(proc.stdout.read()) compile_java("CsMain.java") execute_java("CsMain") </code></pre> <p>but then I got this error:</p> <pre><code>Traceback (most recent call last): File "C:\Python33\lib\subprocess.py", line 1106, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\casestudy\opener.py", line 13, in &lt;module&gt; compile_java("CsMain.java") File "C:\casestudy\opener.py", line 5, in compile_java subprocess.check_call(['javac', java_file]) File "C:\Python33\lib\subprocess.py", line 539, in check_call retcode = call(*popenargs, **kwargs) File "C:\Python33\lib\subprocess.py", line 520, in call with Popen(*popenargs, **kwargs) as p: File "C:\Python33\lib\subprocess.py", line 820, in __init__ restore_signals, start_new_session) File "C:\Python33\lib\subprocess.py", line 1112, in _execute_child raise WindowsError(*e.args) FileNotFoundError: [WinError 2] The system cannot find the file specified &gt;&gt;&gt; </code></pre> <p>the python file and java file is in the same folder, and I am using Python 3.3.2, how can I resolve this? or do you guys have another way on doing this?, any answer is appreciated thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload