Java equivalent of C# system.beep?

You can use this:

java.awt.Toolkit.getDefaultToolkit().beep();

EDIT

If you are trying to play anything of duration and with different sounds you should really look into the Java MIDI library. The default beep won't be able to meet your needs as you can't change the length of the beep.

http://www.oracle.com/technetwork/java/index-139508.html


Just print it:

System.out.println("\007")

Works on Windows and MacOS.


I don't think there's a way to play tunes1 with "beep" in portable2 Java. You'll need to use the javax.sound.* APIs I think ... unless you can find a third-party library that simplifies things for you.

If you want to go down this path, then this page might give you some ideas.


1 - Unless your users are all tone-deaf. Of course you can do things like beeping in Morse code ... but that's not a tune.

2 - Obviously, you could make native calls to a Windows beep function. But that would not be portable.