Launching applications from java code

November 30

I have found a solution to launch applications from java.I thought this will be useful for programmers who want to open a
1. Browser
2. Player
3. Files etc.
There are 2 solutions :
I)To use a known application :
eg: to open windows media player
String[] cmd = new String[3];
cmd[0] = "cmd.exe";
cmd[1] = "/C";
cmd[2] = "START MPLAYER2.exe "+mediaURL+" /PLAY /CLOSE /FULLSCREEN";
//eg: mediaURL = "\"D:/project/songs/track1.mp3\""
// /PLAY /CLOSE /FULLSCREEN this option can be used only for windows media player
// for any other application use cmd[2] as START apl.exe //apl can be any windows application
Process p = Runtime.getRuntime().exec(cmd);
II) To use a default application:
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
// url can be any url
ref: [|]
Edited by: veda_sishta on ? ?????, ???? ??:?? ???????
Edited by: veda_sishta on ? ?????, ???? ??:?? ???????



To post code, use the code tags -- [code]Your Code[/code] will display asYour CodeOr use the code button above the editing area and paste your code between the {code}{code} tags it generates.
And make up your mind what file type you're having a problem with. Maybe .asx doesn't have a file association on your computer.
This works just fine for .m3u:import java.awt.Desktop;
public class Playlist {
   public static void main(String[] args) {
      try {
               open(new File("E:/Music/Playlists/test.m3u"));
      } catch (IOException ex) {
edit Did you try searching the net for the error you got? ("Invalid menu handle")
Edited by: Darryl.Burke

View 7 Replies


  1. hp 2000-2313tu clean install os
  2. sap sq02
  3. Free youtube settings sa nokia503
  4. ipod touch 4 dont recognise ppc g5
  5. aplicativos de 2 dolares na app store
  6. imovie program for a1151
  7. PEXR 2002
  8. rounding off in PR to PO
  9. pr to po rounding
  10. QS8E
Copyrights 2019 Fcffair BigData Resource, All rights reserved