java - Substitutes for unix shell commands for windows? -


i developing source code judging software.i have developed on linux platfrom ubuntu 12.04 lts.

now want deploy on windows. software creating commands per unix shell,saving them in file , executing commands through file. here part of code:

package codejudge.compiler.languages;  import java.io.bufferedwriter; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.outputstreamwriter;  import codejudge.compiler.timedshell;  public class c extends language {      string file, contents, dir;     int timeout;      public c(string file, int timeout, string contents, string dir) {         this.file = file;         this.timeout = timeout;         this.contents = contents;         this.dir = dir;     }     public void compile() {         try {             bufferedwriter out = new bufferedwriter(new outputstreamwriter(new fileoutputstream(dir + "/" + file)));             out.write(contents);             out.close();             // create compiler script             out = new bufferedwriter(new outputstreamwriter(new fileoutputstream(dir + "/compile.sh")));             out.write("cd \"" + dir +"\"\n");             out.write("gcc -lm " + file + " 2> err.txt");             out.close();             runtime r = runtime.getruntime();             process p = r.exec( dir + "/compile.sh");             p.waitfor();             p = r.exec(dir + "/compile.sh"); // execute compiler script             timedshell shell = new timedshell(this, p, timeout);             shell.start();             p.waitfor();         } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } catch (interruptedexception e) {             e.printstacktrace();         }     }      public void execute() {         try {             // create execution script             bufferedwriter out = new bufferedwriter(new outputstreamwriter(new fileoutputstream(dir + "/run.sh")));             out.write("cd \"" + dir +"\"\n");              out.write("./a.out < in.txt > out.txt");             out.close();             runtime r = runtime.getruntime();             process p = r.exec(dir + "/run.sh");             p.waitfor();             p = r.exec(dir + "/run.sh"); // execute script             timedshell shell = new timedshell(this, p, 3000);             shell.start();             p.waitfor();                     } catch (filenotfoundexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         } catch (interruptedexception e) {             e.printstacktrace();         }     } } 

when running same code on windows getting following erros( ihave mingw installed on windows):

codejudge compilation server running ... compiling garima.c... java.io.ioexception: cannot run program "c:\xampp\htdocs\project\codejudge-compiler\stage\1/compile.sh": createprocess error=193, %1 not valid win32 application     @ java.lang.processbuilder.start(unknown source)     @ java.lang.runtime.exec(unknown source)     @ java.lang.runtime.exec(unknown source)     @ java.lang.runtime.exec(unknown source)     @ codejudge.compiler.languages.c.compile(c.java:41)     @ codejudge.compiler.requestthread.run(requestthread.java:65) caused by: java.io.ioexception: createprocess error=193, %1 not valid win32 application     @ java.lang.processimpl.create(native method)     @ java.lang.processimpl.<init>(unknown source)     @ java.lang.processimpl.start(unknown source)     ... 6 more java.io.filenotfoundexception: c:\xampp\htdocs\project\codejudge-compiler\stage\1\err.txt (the system cannot find file specified)     @ java.io.fileinputstream.open(native method)     @ java.io.fileinputstream.<init>(unknown source)     @ java.io.fileinputstream.<init>(unknown source)     @ codejudge.compiler.requestthread.compileerrors(requestthread.java:90)     @ codejudge.compiler.requestthread.run(requestthread.java:66) java.io.ioexception: cannot run program "c:\xampp\htdocs\project\codejudge-compiler\stage\1/run.sh": createprocess error=193, %1 not valid win32 application     @ java.lang.processbuilder.start(unknown source)     @ java.lang.runtime.exec(unknown source)     @ java.lang.runtime.exec(unknown source)     @ java.lang.runtime.exec(unknown source)     @ codejudge.compiler.languages.c.execute(c.java:65)     @ codejudge.compiler.requestthread.run(requestthread.java:72) caused by: java.io.ioexception: createprocess error=193, %1 not valid win32 application     @ java.lang.processimpl.create(native method)     @ java.lang.processimpl.<init>(unknown source)     @ java.lang.processimpl.start(unknown source)     ... 6 more java.io.filenotfoundexception: c:\xampp\htdocs\project\codejudge-compiler\stage\1\out.txt (the system cannot find file specified)     @ java.io.fileinputstream.open(native method)     @ java.io.fileinputstream.<init>(unknown source)     @ java.io.fileinputstream.<init>(unknown source)     @ codejudge.compiler.requestthread.execmsg(requestthread.java:106)     @ codejudge.compiler.requestthread.run(requestthread.java:77) 

i have little knowledge of win32 shell commands..what changes required made code ie. commands should changed not run on windows? , substittes windows?

you can use gnuwin32 tasks.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -