Skip to Main Content

New to Java

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!

UNIX "export" Command from Java

807597Sep 13 2005 — edited Sep 13 2005
Hi,

Am facing a problem while exeuting UNIX command from java. Am attaching the code which I am trying to execute.
import java.io.*;

public class RunCommandExample {

    public static void main(String args[]) {

        String s = null;
        try 
		{
            Runtime.getRuntime().exec("password=midware1");
			//p = Runtime.getRuntime().exec("export password");
			System.exit(0);
        }
		catch (IOException e) 
		{
            System.out.println("[IOException]. Printing Stack Trace");
            e.printStackTrace();
            System.exit(-1);
        }
    }
}
This gives me the following error.

[IOException]. Printing Stack Trace
java.io.IOException: password=midware1: not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:52)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at RunCommandExample.main(RunCommandExample.java:24)

Please let me know the solution for this problem.

Waiting for your valuable replay..

Thanks in advance,
Ashly.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 11 2005
Added on Sep 13 2005
2 comments
1,654 views