473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Playing beep sound on J2SE

539 512MB
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 9209
myusernotyours
188 100+
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 512MB
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(Lithium/Nickel) battery above the RAM port, or similar....

Not the external(connected 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 Expert 2GB
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 100+
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 Expert 2GB
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.println('\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 512MB
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 8TB
...

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 Expert 8TB
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 Expert 1GB
I hate it when programs beep.
Aug 25 '08 #10
JosAH
11,448 Expert 8TB
I hate it when programs beep.
Especially for you I am going to play Ludwig von Beethoven's Symphony #9
for an irritating little computer beep thingy:

an'a one, an'a two, an'a one, two, three four! Maestro!

<beep><beep>><bip><boooooop>
<baap><baap><bep>>booooooooop>
<bip><bip><bip><bip><bip><bip><bip><bip><bwooop>
<bip><bip><bip><bip><bip><bip><bip><bip><bip><bwaa aaap>
<da capo al fine/>

kind regards,

Jos ;-)
Aug 25 '08 #11

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

Similar topics

1
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...
0
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...
2
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...
5
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
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...
3
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...
4
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()...
4
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
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? ...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.