Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Java Language
Expertise: Beginner
Dec 23, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Generating Beep

I want to alert the user of my application with an ASCII 7 bell character. When I run the application from a prompt and use System.out.println((char)7) I get the result I am after. However, when I use jrew.exe to eliminate the command prompt window this method no longer works. Whats the solution for using jrew.exe and processing an ASCII 7 character?

Emitting a beep such as that generated by the ASCII bell character is a platform dependent issue. Not every platform supports the notion of a command line shell with standard output where an ASCII bell character can be turned into an audible sound. Therefore the designers of Java allowed the generation of a beep through the java.awt.Toolkit class which provides the interface to system dependent features through which the AWT is implemented. The Toolkit class possesses a method called beep() which can be used to sound an alert bell as demonstrated by the following simple example:

import java.awt.*;

public final class Beep {
  public static final void main(String[] args) {
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date