Beep Java

Lets learn how to create beep using java. We can create a beep sound to indicate a warning or error.

Beep Java


Lets learn how to create beep using java.

We can create a beep sound to indicate a warning or error by using java. However, it is often better to give a warning dialog box with a description about  the problem using GUI interface.

There are  two ways to produce the sound beep:
1.Using Toolkit class: We can create a beep using Toolkit class. For this we first need to import java.awt.Toolkit. This class provides beep() method to create beep sound. The following syntax is used to create beep using Toolkit class:
import java.awt.Toolkit;
Use this statment in your code:
This is not always a sufficient way to alert the user as there may not be speakers on the user's computer.
2.Using ASCII value: ASCII refer as American Standard Code for Information Interchange. We use ASCII value "\007" to produce bee
p. As we are using in our example.

Here is the code of the program :

import java.util.*;
public class Beep{

  public static void main(String[] args) {



Download this example.

Share on Google+Share on Google+

Beep Java

Posted on: June 19, 2007 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Beep Java   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
October 11, 2011

loops are hard, let's go shoping
November 12, 2011

i satisfied for this website