
-----------------------------------
vicml21
Tue May 30, 2006 4:02 pm

one small quick question
-----------------------------------
i was wondering if anyone knew the code to open a file, using its default program. For example, open a text file using notepad, or open a music file using windows media player, like for Turing, it is:

Sys.Exec("C:/File.txt")

or something like that. thanks in advance.

-----------------------------------
Tony
Tue May 30, 2006 4:16 pm


-----------------------------------
oddly enough it's [url=http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String)]exec()

-----------------------------------
vicml21
Tue May 30, 2006 5:19 pm


-----------------------------------
hmm i looked it up a bit online too, and couldnt get it to run. Basically what im trying to do is run a *.asx file (playlist) in windows media player when the button "Flow" is pressed. It's all included in the zip (java files & the *.asx file im trying to play)

-----------------------------------
Tony
Tue May 30, 2006 5:26 pm


-----------------------------------
does the line you are trying to execute works from command-line console? (cmd)

-----------------------------------
vicml21
Tue May 30, 2006 5:30 pm


-----------------------------------
no, it keeps telling me "command failed" (the message i get when it throws an exception, and doesnt run the file). Ive tried a couple of different ways to use the code, but none of them that I've found worked.

-----------------------------------
rizzix
Tue May 30, 2006 8:35 pm


-----------------------------------
I believe to get this functionality in windows (through the command line) you need to execute "start", as in "start blabla.asx"

-----------------------------------
vicml21
Tue May 30, 2006 9:50 pm


-----------------------------------
hmm.. im not sure what you mean. like if the file was in the same folder, and i wanted to open Flow.asx in windows media player, what would the code look like?

-----------------------------------
Tony
Tue May 30, 2006 9:56 pm


-----------------------------------

Mplayer2.exe /play C:\location\Flow.asx


-----------------------------------
rizzix
Tue May 30, 2006 10:30 pm


-----------------------------------
Or as mentioned before (but I haven't tested it) start ./Flow.asx

-----------------------------------
vicml21
Tue May 30, 2006 11:46 pm


-----------------------------------
well the "start ./Flow.asx" works in cmd to run the file. but i was wondering.. how would i use this in java program?

-----------------------------------
[Gandalf]
Wed May 31, 2006 9:42 pm


-----------------------------------
Anything you can type in the command prompt will work with the exec() method Tony posted.

-----------------------------------
vicml21
Fri Jun 02, 2006 12:19 am


-----------------------------------
well i just got it to open regular *.exe's, regular websites (on my comp anyway), and *.bat files. I could use the *.bat files to run the cmd commands, but if anyone else knows anyway to run any random file (with no specific extension, not just bat & exe), i would greatly appreciate it!

-----------------------------------
rizzix
Fri Jun 02, 2006 11:26 am


-----------------------------------
I thought start  was supposed to do just that. It should open the  with the default application.
