Solved

How to play a sound from the shell with java ?

Posted on 2004-03-30
9
217 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 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

730 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