I have a stateless session bean deployed in JBoss from which I want to execute ceratin Unix Commands.For this I am writing inside my EJB the following code:
Runtime.getruntime().exec("mkdir directory",null,new File(workspace));
Runtime.getruntime().exec("tar -xvf filename",null,new File(workspace));
I have deployed this bean in JBoss.But erratically it gives error at runtime when the code gets called and exits in between.It gives either of the following exceptions:
Since it is not recommended to start process from EJB,pls suggest an alternate solution to it.
File f = new File("/path/to/directory");
This is a little more difficult as tar is not support by Java out of the box. If your file was a zip (or a jar) then you could use the java.util.zip packages to unzip the file. As for tar either write you own tar file handler or find one off the web (The Apache Ant software has an implementation).
why don't you write a shell script to create directory and tar. pass filename as an argument. Probably this issue suffice a single call to make all these things