Friday, 15 April 2011

java - Is it Possible to compile a Python Source file in Eclipse via Command Prompt? -



java - Is it Possible to compile a Python Source file in Eclipse via Command Prompt? -

i have been able able compile c programme in eclipse works perfectly. have installed python interpreter , set environment variables in windows.

these codes c. how modify compile .py(python) source file.thanks

public class c_compile { public static void main(string args[]){ string ret = compile(); system.out.println(ret); } public static string compile() { string log=""; string mydirectory = "c:\\"; seek { string s= null; //change string compilers location process p = runtime.getruntime().exec("cmd /c gcc hello.c", null, new java.io.file(mydirectory)); bufferedreader stderror = new bufferedreader(new inputstreamreader(p.geterrorstream())); boolean error=false; log+=""; while ((s = stderror.readline()) != null) { log+=s; error=true; log+="\n"; } if(error==false) log+="compilation successful !!!"; } grab (ioexception e) { e.printstacktrace(); } homecoming log; } public int runprogram() { int ret = -1; seek { runtime rt = runtime.getruntime(); process proc = rt.exec("cmd.exe /c start a.exe"); proc.waitfor(); ret = proc.exitvalue(); } grab (throwable t) { t.printstacktrace(); homecoming ret; } homecoming ret; }}

by default, eclipse doesn't have python run-time. pydev popular plugin eclipse provides functionality.

quoting pydev's website:

pydev python ide eclipse, may used in python, jython , ironpython development.

however, if looking running command prompt, , have python environment variable set, can utilize command python <path>, path relative/absolute path python source file.

java python eclipse cmd

No comments:

Post a Comment