Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to play a sound from the shell with java ?

Posted on 2004-03-30
9
Medium Priority
?
220 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
[X]
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
  • 3
  • 2
  • 2
9 Comments
 
LVL 92

Expert Comment

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

Accepted Solution

by:
objects earned 200 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
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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

610 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