Java – the toolkit does not beep on Ubuntu
I have a problem with the toolkit beep I'm in / etc / modprobe d/blacklist. Two speaker disable lines are commented out in conf I can't use console code 7 to beep because I need it to work in swing, and I want it to be heard in the eclipse IDE (instead of displaying special symbols in a console like pane in eclipse) When not in the eclipse IDE, I tested code 7 and found it audible, so I knew it wasn't a loose connector problem I passed WAV files do have good sound effects, but sometimes I just want a simple beep. I don't want to use a lot of CPU cycles to implement it I am currently using runtime getRuntime(). Exec ("beep"), but this seems a little too much I'm on Ubuntu 10.10 The computer board is Gigabyte Ma 770 UD3 The following is the violation plan
import java.awt.Toolkit; public class Beeper { public static void main(String[] args) { Toolkit.getDefaultToolkit().beep(); } }
From blacklist Conf is as follows
# low-quality,just noise when being used for sound playback,causes # hangs at desktop session start (Ubuntu: #246969) #blacklist snd_pcsp # ugly and loud noise,getting on everyone's nerves; this should be done by a # nice pulseaudio bing (Ubuntu: #77010) #blacklist pcspkr
Solution
I guess your pcspks module is not loaded... I have the same problem and found that it is not in my system (14.04 LTS)
Check whether grep pcspkr is loaded in the terminal by executing lsmod | If you get a similar line
pcspkr 12718 0 `
It is loaded If you do not get any output from the command, try loading the module:
sudo modprobe pcspkr
It works for me