Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes Can't beep() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic
Author

Can't beep()

Jim Goodwin
Greenhorn

Joined: Sep 15, 2000
Posts: 14
How does one make a Java application beep?
I've tried Toolkit.getDefaultToolkit().beep();
and it compiles and executes but makes no sound.
I am very unfamiliar with the whole Toolkit idea
so I may be doing something really dumb. Apologies
if this is not an "advanced" question!
I'm running Sun jdk 1.3 on Windoze NT 4, sp6.
Jim
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
<code><pre>import java.awt.*;

public class Test {
public static void main(String[] s) {
Toolkit.getDefaultToolkit().beep();
}
}</pre></code>
That should do it, I'd think - it does on my system anyway. However my machine at work is set up with no speaker at all - the only way I can hear the beep is if I plug headphones into the audio out in back of the box. Can you hear beeps normally? E.g. go to Start -> Settings -> Control Panel -> Sounds - you should be able to play a variety of sounds on your system. If you don't hear them, you need to find a way to enable sounds on your system first.
I hope the above was useful; otherwise I have no idea.


"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
So Jim, beep in java is not going to play through your system speaker, but throught your sound card?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
The beep() in Java should be played however a beep is normally played on your system. My work setup doesn't seem to have any sort of speaker, period - the only way I hear anything from it is by hooking something up to the audio out. I don't know anything about how it's hooked up internally.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't beep()
 
Similar Threads
Beep Sound continuously for 1 min??
Beep sound - How to generate?
WA#2 word association
Making it beep
How to get Beep Sound during error??