Launching applications from java code

Advertisement
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: [http://forums.sun.com/thread.jspa?threadID=5203313|http://forums.sun.com/thread.jspa?threadID=5203313]
[http://www.ericphelps.com/batch/rundll/|http://www.ericphelps.com/batch/rundll/]
Edited by: veda_sishta on ? ?????, ???? ??:?? ???????
Edited by: veda_sishta on ? ?????, ???? ??:?? ???????

Advertisement

Replay

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;
import java.io.File;
import java.io.IOException;
public class Playlist {
   public static void main(String[] args) {
      try {
         Desktop.getDesktop().
               open(new File("E:/Music/Playlists/test.m3u"));
      } catch (IOException ex) {
         ex.printStackTrace();
}db
edit Did you try searching the net for the error you got? ("Invalid menu handle")
Edited by: Darryl.Burke

View 7 Replies

Tags:

  1. sattellite l650 1mm system unit psk1 je
  2. youtube does not open safari mac kids ç
  3. ba amex cli when bad credit
  4. KE30 and SAP
  5. BAPI_SALESDOCUMENT_CHANGE sample
  6. mass confirm vendor
  7. package4uu
  8. listendno
  9. speed866
  10. officery2h
Copyrights 2019 Fcffair BigData Resource, All rights reserved