When I try to get a beep by using Toolkit.getDefaultToolkit().beep()
, it does not seem to work on any of my Windows computers. I also know someone who has the same problem, but they say it works on other OS's. Does anyone know why?
Asked
Active
Viewed 1.7k times
6

syb0rg
- 8,057
- 9
- 41
- 81

Daniel Causebrook
- 469
- 1
- 8
- 20
2 Answers
10
For me, the problem was that I had "No Sounds" configured (Win7 Pro). After changing this back to "Windows Default", I was able to hear the beep (actually a 'ding') - also when started from within eclipse.

Reto Höhener
- 5,419
- 4
- 39
- 79
6
This code works for me on Windows 7, make sure you don't have your sound muted.
import java.awt.*;
public class Beep {
public static void main(String... args) {
Toolkit.getDefaultToolkit().beep();
}
}
You could also just print the ASCII
representation for the bell, also works on Windows 7
public class Beep {
public static main(String... args) {
System.out.print("\007"); // \007 is the ASCII bell
System.out.flush();
}
}

syb0rg
- 8,057
- 9
- 41
- 81
-
1OK, I will have to check with the other person who has that problem, I may not have understood him correctly. I will find out next week. – Daniel Causebrook Mar 15 '13 at 21:12