• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use of Runtime.getRuntime().exec

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ??
 
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 7590
177
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the java.awt.Desktop class.
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that is url of that media file that i tried to open
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i mean address of th file i tried to open
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult for “beginning”. Moving discussion.
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright sir
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but m still not getting how to open the drives and different media or different format of file
 
Tim Moores
Saloon Keeper
Posts: 7590
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you understand what Jeff said? Did you read the javadocs for that method and understand those?
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ye Tim i did
 
jaspreet manchinda
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

 
reply
    Bookmark Topic Watch Topic
  • New Topic