Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 one small quick question
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vicml21




PostPosted: Tue May 30, 2006 4:02 pm   Post subject: 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:

code:
Sys.Exec("C:/File.txt")


or something like that. thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Tue May 30, 2006 4:16 pm   Post subject: (No subject)

oddly enough it's [url=http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String)]exec()[/url]
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
vicml21




PostPosted: Tue May 30, 2006 5:19 pm   Post subject: (No subject)

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)


zip.zip
 Description:
3 files: 2 java, one *.asx file.

Download
 Filename:  zip.zip
 Filesize:  1.17 KB
 Downloaded:  60 Time(s)

Tony




PostPosted: Tue May 30, 2006 5:26 pm   Post subject: (No subject)

does the line you are trying to execute works from command-line console? (cmd)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
vicml21




PostPosted: Tue May 30, 2006 5:30 pm   Post subject: (No subject)

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




PostPosted: Tue May 30, 2006 8:35 pm   Post subject: (No subject)

I believe to get this functionality in windows (through the command line) you need to execute "start", as in "start blabla.asx"
vicml21




PostPosted: Tue May 30, 2006 9:50 pm   Post subject: (No subject)

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




PostPosted: Tue May 30, 2006 9:56 pm   Post subject: (No subject)

http://support.microsoft.com/KB/241422 wrote:

Mplayer2.exe /play C:\location\Flow.asx
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Tue May 30, 2006 10:30 pm   Post subject: (No subject)

Or as mentioned before (but I haven't tested it)
code:
start ./Flow.asx
vicml21




PostPosted: Tue May 30, 2006 11:46 pm   Post subject: (No subject)

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]




PostPosted: Wed May 31, 2006 9:42 pm   Post subject: (No subject)

Anything you can type in the command prompt will work with the exec() method Tony posted.
vicml21




PostPosted: Fri Jun 02, 2006 12:19 am   Post subject: (No subject)

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




PostPosted: Fri Jun 02, 2006 11:26 am   Post subject: (No subject)

I thought start <file> was supposed to do just that. It should open the <file> with the default application.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: