aspose file tools
The moose likes Java in General and the fly likes use of Runtime.getRuntime().exec Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "use of Runtime.getRuntime().exec" Watch "use of Runtime.getRuntime().exec" New topic
Author

use of Runtime.getRuntime().exec

jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
what does Runtime.getRuntime().exec() means and what it is used for
i read it some where that it is used to open different executable files using java
by using this command can i open drives or non-executable files if not then how can i open it ??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Start by reading this article.

Also check out the java.lang.ProcessBuilder class, which is the more modern variant of Runtime.exec.
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
thank you Tim for your reply but how can i open different drives and different files and folder in that drive for example i got some music file of any other file or folder in that drive how can i make it act like it acts on double click by mouse please help...
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Check out the java.awt.Desktop class.
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
thats really cool but when I try to open a media file its giving

java.io.IOException: Failed to open file:/E:/MUZIC/INGLISH/01%20lose%20yourself%
20-%20no%20skips%20-%20guaran.mp3. Error message: Unspecified error

at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
at sun.awt.windows.WDesktopPeer.open(Unknown Source)
at java.awt.Desktop.open(Unknown Source)
at RuntimeExec.main(RuntimeExec.java:17)
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 4901
    
    7

jaspreet manchinda wrote:thats really cool but when I try to open a media file its giving
java.io.IOException: Failed to open file:/E:/MUZIC/INGLISH/01%20lose%20yourself%
20-%20no%20skips%20-%20guaran.mp3. Error message: Unspecified error

Do you actually have a file with that name? Looks like a URL specifier to me.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
that is url of that media file that i tried to open
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

jaspreet manchinda wrote:that is url of that media file that i tried to open


URL != file.

Did you look at the docs for that method? Do they say anything about taking a URL for a parameter?
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
i mean address of th file i tried to open
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Too difficult for “beginning”. Moving discussion.
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
alright sir
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
but m still not getting how to open the drives and different media or different format of file
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2407
Did you understand what Jeff said? Did you read the javadocs for that method and understand those?
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
ye Tim i did
jaspreet manchinda
Ranch Hand

Joined: Feb 27, 2012
Posts: 64
This will give you an idea


java.io.IOException: Failed to open file:/E:/MUZIC/Eminem%20-%20Recovery%202010/
Eminem-Recovery-2010/3.%20On%20Fire.mp3. Error message: Unspecified error

at sun.awt.windows.WDesktopPeer.ShellExecute(Unknown Source)
at sun.awt.windows.WDesktopPeer.open(Unknown Source)
at java.awt.Desktop.open(Unknown Source)
at RuntimeExec.main(RuntimeExec.java:21)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use of Runtime.getRuntime().exec
 
Similar Threads
How to run a java class file using exec
open ms-word on web
trouble with Runtime.exec()
Compiling Java with Java
Running a program from a Java Application