Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute UNIX script from java not working

807580Jan 28 2010 — edited Feb 4 2010
Hi

I am having difficulty running my java program to execute UNIX script on a Windows box. Here is my code.
public boolean executeScript() {
		try {
			String testScript= "WEB-INF/scripts/test.sh";
			File file = new File(copyToQaScript);
			System.out.println(file.getAbsolutePath());
			Process proc = Runtime.getRuntime().exec(file.getAbsolutePath());
		} catch (IOException ioe) {
			ioe.printStackTrace();
			logger.error(ioe);
		} catch (RuntimeException re) {
			re.printStackTrace();
			logger.error(re);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e);
		}
		return true;
	}
When I execute this method, I am getting IOException as below.

java.io.IOException: CreateProcess: C:\tomcat-5.0.28\webapps\myProject\WEB-INF\scripts\test.sh error=193

Can anyone help me? Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2010
Added on Jan 28 2010
33 comments
1,065 views