473,573 Members | 2,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Playing beep sound on J2SE

539 Contributor
Is there a way to play the alert tone(small speaker) installed on the motherboard from java?

Like the way we call it in C "\a" character...... .. i forgot whats the code to play it in C.... im not sure......
Aug 25 '08 #1
10 9237
myusernotyours
188 New Member
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. public class beep {
  3.   public static void main(String args[]) {
  4.      Toolkit.getDefaultToolkit().beep();
  5.      }
  6.   }
  7.  
  8. }
Regards
Alex.
Aug 25 '08 #2
sukatoa
539 Contributor
Expand|Select|Wrap|Line Numbers
  1. import java.awt.*;
  2. public class beep {
  3.   public static void main(String args[]) {
  4.      Toolkit.getDefaultToolkit().beep();
  5.      }
  6.   }
  7.  
  8. }
Regards
Alex.
Thanks for your reply........ That also beeps.......

But the beep that i was trying to play is from that speaker:

Installed in the Motherboard,
Cylindrical form (less than an inch diameter, half an inch height) speaker...
Near the rechargeable(Li thium/Nickel) battery above the RAM port, or similar....

Not the external(connec ted in audio port)....

For example, when we unplug the harddisk(Get out from IDE/SATA), then start the PC, that beep(Morse type) signifies that a required harddrive must be plugged-in.....

Another example is from the mysql command-prompt.... that when we got the wrong query, that speaker also beeps......

But, anyway thanks for your reply......
sukatoa
Aug 25 '08 #3
Nepomuk
3,112 Recognized Expert Specialist
To beep with the mainboard speaker, use this:
Expand|Select|Wrap|Line Numbers
  1. System.out.println("\007");
  2. System.out.flush();
However, this might not work within an IDE like Eclipse - it will however work when calling your program from command line.

Greetings,
Nepomuk
Aug 25 '08 #4
myusernotyours
188 New Member
Any one Knows why this does not work with an IDE? Even in netbeans no beep sounds. And I also found that a SplashScreen does not work in an IDE either. Makes one feel shortchanged if an IDE can't support such 'simple' stuff.
Aug 25 '08 #5
Nepomuk
3,112 Recognized Expert Specialist
Any one Knows why this does not work with an IDE? Even in netbeans no beep sounds. And I also found that a SplashScreen does not work in an IDE either. Makes one feel shortchanged if an IDE can't support such 'simple' stuff.
I don't know about the SplashScreens, but the beep sound is not played because the standard output goes to the IDE instead of "normal" stdio and is not forwarded from there. You could probably make it beep by writing a simple C program like
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main()
  3. {
  4.    printf("\a");
  5. }
and calling that from Java. Not a nice way to do it, I admit, but it should work. Or course, this C file would have to be recompiled for every platform you use it on, but if it's just for developement...

By the way, you can use
Expand|Select|Wrap|Line Numbers
  1. System.out.println('\b');
too - it does the same as System.out.prin tln('\007').

Probably the best option is just to test your program with the command line ever so often, to make sure all of the beeps are at the right place.

Greetings,
Nepomuk
Aug 25 '08 #6
sukatoa
539 Contributor
Thanks for replies guys.....

Can i request to admin?

To change the title into "Playing beep sound on J2SE" or near to this topic?

Alert tone sounds like J2ME......

I've attempted searching about this topic, and all i've got is a sample for J2ME.....


Thanks again,
sukatoa
Aug 25 '08 #7
r035198x
13,262 MVP
...

Can i request to admin?

To change the title into "Playing beep sound on J2SE" or near to this topic?

..
That will be two nickels ...
Aug 25 '08 #8
JosAH
11,448 Recognized Expert MVP
Any one Knows why this does not work with an IDE? Even in netbeans no beep sounds. And I also found that a SplashScreen does not work in an IDE either. Makes one feel shortchanged if an IDE can't support such 'simple' stuff.
It all depends on the terminal (emulation) capabilities; there are a lot of Unicode
ISO control characters; I never see any bold (or stretched out) font characters
following an SO character either. Look here for all of them; most are forgotten.

kind regards,

Jos
Aug 25 '08 #9
BigDaddyLH
1,216 Recognized Expert Top Contributor
I hate it when programs beep.
Aug 25 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
9281
by: Kiteman \(Canada\) | last post by:
Instead of a beep sound playing as an alarm or reminder I would like to be able to play a more interesting sound. On the web, I found and tried a sound routine that uses the SOUND.DRV but it does not work for me. Maybe it would be best to try to play a small mp3 or wav file instead - does VB 6.0 have built-in support for sounds like that?...
0
1908
by: Put 030516 in email subj to get thru | last post by:
I'm trying to learn about Java MIDI programming. Specifically, I'm interested in playing with Java MIDI sequencers (all puns intended). I'm looking at java.sun.com/j2se/1.4.2/docs/guide/sound/programmer_guide for most of my information. Is it possible to give the sequencer near future input notes to play *while* the sequencer is already...
2
8745
by: bill_m | last post by:
Has anyone tried to use the .NET Beep function? The following works in VBA: Private Declare Function Beep Lib "Kernel32.dll" _ (ByVal X As Long, ByVal Y As Long) As Long Dim blVal As Boolean Dim dwFreq As Long Dim dwDuration As Long
5
4084
by: Ike | last post by:
Is there wa way to make the system beep (ascii 007...bell) via javascript (or any other simple notification sound)? Thanks, Ike
3
5461
by: MLH | last post by:
Sound works on my computer. I can play MIDI files, audio CD's. My standard wave files play OK (IE, C:\windows\Media\tada.wav). But running DoCmd Beep doesn't result in a sound. What can I check?
3
2894
by: Thom Little | last post by:
The following code will produce a sound in C# ... using System.Runtime.InteropServices; Beep( 500, 500 ); private static extern bool Beep( int freq, int dur ); How can I play the sound associated with the System "Default Beep"?
4
6863
by: Rich | last post by:
Hello, I want to use the Beep() to alert users about certain messages but in my workstation I can't get a sound out of it. But Beep works in VB6. What do I need to do? Sub... .... Beep() For i = 0 to 100: Beep(): Next
4
1780
by: Ross | last post by:
Anyone have any code that will sound a click from the PC speaker with keystrokes? Any easy way to get a beep out of the PC speaker (not through the sound card)? Thanks, Ross
4
9943
by: =?Utf-8?B?UmljaA==?= | last post by:
When I press the Enter key in a Textbox I get a beep sound. But when I press the Enter key in a combobox, I don't get the beep sound. Is there a way to suppress the beep? How to do this? Thanks
6
2973
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data entry. The data is being put into a text box, and a Return is sent after the data. I use the keypress event to capture the Return, and save the data....
0
7705
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8033
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8206
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5601
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5294
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3739
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2224
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1316
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1044
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.