trouble with execute an command at apache exec in java -
i want run file (a.txt) using apache commons exec libraries . gives me error : problem?
exception in thread "main" java.io.ioexception: cannot run program "a.txt" (in directory "c:\users\sinaa\desktop"): createprocess error=2, system cannot find file specified
my code :
public static void main(string[] args) throws ioexception { executor exec = new defaultexecutor(); file temp=new file("c:\\users\\sinaa\\desktop"); exec.setworkingdirectory(temp); commandline s=new commandline("a.txt"); exec.execute(s); }
from comment:
i want open a.txt in notepad window when compile code
to open file in java using default associated application, use desktop class:
try{ desktop.open("a.txt"); }catch(ioexception io){ io.printstacktrace(); }
Comments
Post a Comment