Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't beep()

 
Jim Goodwin
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does one make a Java application beep?
I've tried Toolkit.getDefaultToolkit().beep();
and it compiles and executes but makes no sound.
I am very unfamiliar with the whole Toolkit idea
so I may be doing something really dumb. Apologies
if this is not an "advanced" question!
I'm running Sun jdk 1.3 on Windoze NT 4, sp6.
Jim
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<code><pre>import java.awt.*;

public class Test {
public static void main(String[] s) {
Toolkit.getDefaultToolkit().beep();
}
}</pre></code>
That should do it, I'd think - it does on my system anyway. However my machine at work is set up with no speaker at all - the only way I can hear the beep is if I plug headphones into the audio out in back of the box. Can you hear beeps normally? E.g. go to Start -> Settings -> Control Panel -> Sounds - you should be able to play a variety of sounds on your system. If you don't hear them, you need to find a way to enable sounds on your system first.
I hope the above was useful; otherwise I have no idea.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So Jim, beep in java is not going to play through your system speaker, but throught your sound card?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The beep() in Java should be played however a beep is normally played on your system. My work setup doesn't seem to have any sort of speaker, period - the only way I hear anything from it is by hooking something up to the audio out. I don't know anything about how it's hooked up internally.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic