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!

Runtime.getRuntime().exec question

843785Oct 21 2008 — edited Oct 22 2008
Hi

I have written an program where i need to open files on my computer with specific commands, but it wont work correctly.

It looks something like this in my Tools class:
public void setCustomCmd (String cmd) {
		customOpenCmd = cmd;
	}

	public void openCustom (String[] path) {		
		String[] uu = new String[path.length + 1];

		uu[0] = customOpenCmd;

		for (int i = 1;i < uu.length;i++) {
			uu[i] = path[i - 1];
		}

		try {
			Process p = Runtime.getRuntime().exec(uu);

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
I am trying to open an array of files with the specified command, like some movies with gmplayer. (im using linux, but it would be good to make this method platform independent). The thing is it "kind of" works. When i give an array with paths to smplayer (an frontend for mplayer) they will be added to the playlist and i can play the movies, but smplayer behaves strange. When i try to open the settings or the file info for instance, smplayer just freezes. Gmplayer also "kind of" works, until i try to close it. It will freeze and i have to kill the process. (in both cases the movie still plays, but the frontend for mplayer itself freezes).

So far i have been able to solve every problem in my learning process of java (and programming in general) with google, but im just unable to make any progress with this problem (and i REALLY have tried everything i can think of). So, can anyone help me?

Also, smplayer does write some output to the terminal when i run it, do i need to handle that from java somehow as well?

Thanks in advice.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 19 2008
Added on Oct 21 2008
7 comments
332 views