8

With the IntelliJ Idea, when setting a breakpoint that doesn't hit frequently (or not at all), I leave my computer. I'll return ~every 10 minutes to check if the breakpoint has been reached. This process would make use of my time more efficient if I could hear when the breakpoint has been reached. Is this possible?

EDIT:

1) The following works as code, but I need to execute an .mp4 file instead of .app. See the second block of code for that attempt, which doesn't work.

2) Though the code works for .app, how would I set the breakpoint to execute that code when it is reached?

This works as code:

try {
   Runtime.getRuntime().exec("/usr/bin/open -a iTunes.app");
} catch (IOException e) {
   e.printStackTrace();
}

This doesn't

try {
   Runtime.getRuntime().exec("MacintoshHD/Users/myusername/Music/iTunes/iTunes Media/Tones -a 01 Zelda Gets Item Alert Tone.m4a");
} catch (IOException e) {
   e.printStackTrace();
}

btw, I did try putting quotes around the path items that had spaces. That didn't work either.

dbconfession
  • 1,147
  • 2
  • 23
  • 36

2 Answers2

4

Add this to Evaluate and log:

    Clip clip = AudioSystem.getClip();
    AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("some.wav"));
    clip.open(inputStream);
    clip.start();
    Thread.sleep(10000);

or execute some application to do it:

try {
   Runtime.getRuntime().exec("\"C:\\Program Files (x86)\\Winamp\\winamp.exe\" \"C:\\some.mp4\"");
} catch (IOException e) {
   e.printStackTrace();
}
Meo
  • 12,020
  • 7
  • 45
  • 52
  • Nice. I took this to the extreme and fixed the import bug with the newer Intellij. https://gist.github.com/philard/b92214e230e3c1de5f6d65b952b3de14 – philard Sep 11 '17 at 09:30
0

If you are on Windows, you can create a very simple script in powershell, which will making a beeping sound whenever it is ran. (This will run at frequency 500 for 3 seconds).

[console]::beep(500,3000)

Then in the evaluate section of the debugger just add a watch variable that calls the script using powershell:

Runtime.getRuntime().exec("powershell.exe \"C:\\Users\\myusername\\test.ps1\"") 
mcsj120
  • 89
  • 1
  • 3