bash - exec from Java: looking up appropriate script executors -


we're writing java application involves letting user execute program withen ours. other program executable, or script, , take number of command line parameters. we've built gui and, in basic functional case, works.

we're using apache exec this, though @ point i'm not sure value giving us.

the problem i'm having known script file types.

if open powershell , type ./myvisualbasicscript.vbs will, internally, translate command wscript.exe ./myvisualbasicscript.vbs. similarly, iirc, in bash if type ./sometcshellscript.tcsh, invoke script under tcshell.

i'm wondering if there's library provide mapping me. ideally library 1 like

commandline cmd = new com.awesome.library.commandline(     pathtoexecutableorscript,     args );  cmd.execute(); 

it nice if such library sported watchdogs , timeouts , signal handling etc, main feature i'm looking kind of method map file types (preferably using both extensions , meta properties) executable runs them.

i've been building map inside our application, , i'm @ least aware of javas java.awt.desktop.open() method, job me, though more tailored toward gui'd applications. i'm not sure if has facilities capture standard in, out, , error, or have watchdogs , timeouts, etc.

any appreciated.

you can use processbuilder so

// create processbuilder. processbuilder p = new processbuilder(); // use command "notepad.exe" , open file. p.command("notepad.exe", "c:\\file.txt"); p.start(); 

or

process p = runtime.getruntime().exec("cmd /c start " + file.getabsolutepath()); 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -