alert and prompt are part of JavaScript as it exists in browsers. The JavaScript supported by Java 6 does not have any GUI elements.
Examples of how to use Java GUI features (if you want the GUI to be part of the script, instead of it being part of the Java application you're scripting) can be
found here.