Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to play a sound from the shell with java ?

Posted on 2004-03-30
9
216 Views
Last Modified: 2010-03-31
Simple... I am using Linux and Java.

In C++ I can make a program that calls a system function and allows me to play a sound from the shell. The call to the system function is:

System("play mysound.wav");

Is it there any way to do the same thing with Java... so I could call the same "play" function from the shell and the sound will be played ?

If there is some class I need to include, please tell me and tell me how.

Do not send me to complicated plages or give me some complicated code... I guess it should be simple.
0
Comment
Question by:digi_mind
  • 3
  • 2
  • 2
9 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10717860
Use Runtime.exec();
0
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 10717866
Process p = Runtime.getRuntime().exec(command);
0
 

Author Comment

by:digi_mind
ID: 10717982
It does not work

 Use Runtime.exec();
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10718023
Runtime.getRuntime().exec("play mysound.wav");
0
 
LVL 92

Expert Comment

by:objects
ID: 10718091
what command did you try?
Try using the full path to the executable and sound file.
0
 

Author Comment

by:digi_mind
ID: 10718421
Runtime.getRuntime().exec("play mysound.wav");

That command does not work... I have another one now which is more complicated, but works.

Runtime sound = Runtime.getRuntime();
sound.exec("play alarm.wav");

I share the code with you.
0
 
LVL 14

Expert Comment

by:Tommy Braas
ID: 10718760
>> Runtime sound = Runtime.getRuntime();
>> sound.exec("play alarm.wav");

Is functionally the same as:

>> Runtime.getRuntime().exec("play alarm.wav");

That is what we suggested, except that you're using "play alarm.wav". We merely based our responses on what you had provided in your question.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
nextBoolean(double p) for Random class 3 41
type mismatch (Object[] to double[] 4 32
Facing this issue for maven proxy setting 2 19
java imports not found 4 16
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

790 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