how to invoke cygwin thorugh java shell? -


i have code meant linux execute .sh files on unix shell.

i wanted run same code windows. told should install cygwin windows. did how redirect commands cygwin shell?

here part of code:

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");          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();     } } 

how redirect cygwin shell , run shell scripts? code example helpful lot. been bugging myhead couple of days on this

exec c:/cygwin/bin/bash.exe (or c:/cygwin/bin/sh.exe, or whatever path cygwin /bin/<shell>.exe is), , pass script argument.

there's 1 more wrinkle though. there isn't full-featured jvm cygwin-native, you'll using jvm installed , used windows. means value of 'path' , other environment variables may not expect when start shell, , may need use cygpath convert paths passed java windows paths cygwin paths, possibly including value of $0.


Comments

Popular posts from this blog

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

qt - Errors in generated MOC files for QT5 from cmake -