This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Can Watch "Can New topic

Can't beep()

Jim Goodwin

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 Yingst

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

public class Test {
public static void main(String[] s) {
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
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

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.
I agree. Here's the link:
subject: Can't beep()
It's not a secret anymore!