Personal Developer Notebook

Embedding Flash Into Java Applications

To be able to embed Flash into a Java application one needs a third party library. ComfyJ from TeamDev is such a library.

ComfyJ is a bidirectional Java-COM bridge which allows me to use ActiveX/COM objects from Java.

Here a screenshot with a SWF running inside a Java Swing user interface:


In Java the initialization looks like:

private static final String FLASH_PROGID = "ShockwaveFlash.ShockwaveFlash";
    private OleContainer _container = new OleContainer();



        getContentPane().add(_container, BorderLayout.CENTER);
        addWindowListener(new WindowAdapter()
            public void windowOpened(WindowEvent e)

            public void windowClosing(WindowEvent e)

Some simple helper methods:

private void createOleObject()

    private void showOleObject()

    private void destroyOleObject()

To open a SWF file:

OleMessageLoop.invokeMethod(this, "openFile", new Object[]{filename});

And finally here is the openFile method:

public void openFile(String filePath)
        File file = new File(filePath);

        if(!file.exists()) {
            throw new RuntimeException("Couldn't find file with movie: " + filePath);

        IDispatchImpl flash = new IDispatchImpl(_container.getOleObject());
        Automation flashAutomation = new Automation(flash);

        // load movie
        flashAutomation.setProperty("Movie", filePath);

The class path should look similar to:


And don’t forget to pass a parameter to the Java VM with the (relative) path to the folder with the native DLLs:


BTW, I’m not associated with TeamDev other than being a mostly happy user. Here’s the link to the library: