This is sort of a grey area. If your images are low-resolution & your book is educational, I don't think anyone will sue (although Oracle might if they don't like you for some other reason, & a couple other vendors have a history of doing the same).
If you want to be very safe, either get permission or redraw the interface by hand in a way that removes any trademarkable icons.