This is because you are trying to redefine an already defined class JOptionPane
, just rename your class and it should be fine
class JOptionPaneDemo
{
// continue
Also since you'd have to define this in "JOptionPaneDemo.java", you can compile and run this as
javac JOptionPaneDemo.java
java JOptionPaneDemo