[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

running a system command

Posted on 2005-04-24
6
Medium Priority
?
160 Views
Last Modified: 2011-09-20
let's say I want to execute "c:\somefile.wmv" and because it is associated with an application, it should run.  Is it possible to specify a system command for a standalone swing gui?

Thanks,
David
0
Comment
Question by:lomidien
  • 4
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13855025
Yes. If you put it into an executable jar it *should* run by default in javaw
0
 

Author Comment

by:lomidien
ID: 13855030
What I mean is....is there a method by which I can execute a shell command?  Could be anything.... a .bat, .wmv, .mp3, etc.

Thanks,
David
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13855031
If by some chance you mean 'how do i run *.wav from Java?' you can do:

Runtime.getRuntime().exec("cmd.exe /C start somefile.wav");
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 13855034
That should work for anything with an assoc:

Runtime.getRuntime().exec("cmd.exe /C start " + fileName);
0
 

Author Comment

by:lomidien
ID: 13855054
Perfect, thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13855109
:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question