Could we add \a as an escape sequence for bell?

David Alayachew davidalayachew at gmail.com
Sun Oct 26 17:05:53 UTC 2025


Hello @core-libs-dev <core-libs-dev at openjdk.org>,

In languages such as C and Python, the escape sequence \a corresponds to
the "Bell" character <https://en.wikipedia.org/wiki/Bell_character>,
commonly used to trigger the system default bell or notification, even
producing a small flash or audio. For example, on Windows 11, printing the
Bell character causes an audio notification to play, and whatever
application that printed it will flash orange on the taskbar on the bottom
of my screen.

This is super useful for notifying the end of a process that you aren't
actively monitoring. Like I mentioned, not only does it make an audio
notification, but it also causes the taskbar icon to flash. Great for
multitasking.

Since this is something useful (and it already exists in several other
languages), could we add it to Java too?

We can already do this now, with the following command (try it in JShell!).

final char bell = 7;
Thread.sleep(java.time.Duration.ofSeconds(5));
System.out.println(bell);

Try and switch to a different window, and you will see that, not only will
the bell sound, but you are likely to have your taskbar icon flash.

So, could we have \a as an escape sequence character?

If not that, could we have it be a static field or static method in some
class? Maybe Character.bell() or System.bell()? I think it's useful enough
to deserve it.

Of course, if none of that makes sense, and we should just stick to typing
char bell = 7 and just using that, that's fine too. But please lmk either
way.

Thank you for your time and consideration.
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20251026/8372a0ba/attachment-0001.htm>


More information about the core-libs-dev mailing list