A Windows screen saver is just program that accepts certain command line arguments. So in order to have your program be runnable as a screen saver you must code it to accept those arguments.
Next you will probably want your screen saver to run in full screen mode. This is very simple to do in Java as the example below shows:
public final class ScreenSaver {
public static final void main(final String[] args) throws Exception {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
final JFrame screenSaverFrame = new JFrame();
screenSaverFrame.setDefaultCloseOperation(
WindowConstants.EXIT_ON_CLOSE);
screenSaverFrame.setUndecorated(true);
screenSaverFrame.setResizable(false);
screenSaverFrame.add(new JLabel("This is a Java Screensaver!",
SwingConstants.CENTER), BorderLayout.CENTER);
screenSaverFrame.validate();
GraphicsEnvironment.getLocalGraphicsEnvironment()
.getDefaultScreenDevice()
.setFullScreenWindow(screenSaverFrame);
}
}
Finally you will need to make your Java program into a Windows executable using something like Launch4j and give it .scr
extension.