Over a million developers have joined DZone.

NetBeans External Execution of ZX Spectrum Emulator on Ubuntu

DZone's Guide to

NetBeans External Execution of ZX Spectrum Emulator on Ubuntu

· Java Zone ·
Free Resource

Atomist automates your software deliver experience. It's how modern teams deliver modern software.

A very good day for me yesterday. I discovered this link:


It turns out that a simple "sudo apt-get" gets you a ZX Spectrum emulator! With a world of games. Hello "Chuckie Egg"! Hello "Daley Thompson's Decathlon"! Old friends. Old, old friends!

Before I knew it, I had some very simple integration with the NetBeans Platform, such that I could launch the command line tool. Then I had access to the emulator, as well as the keyboard while working in NetBeans IDE:

And see? I was also able to load my games, from the IDE's Output window. (Not the ideal user interface, of course, but fun anyway.) Then I ended up being back at school, playing "Skool Daze" and getting punished for sitting on the floor, punching my fellow students, and skipping class:

It was, above everything else, a chance to try out a new NetBeans API that will be part of the next release, the External Execution API, which its author, Petr Hejl, has blogged about very well here and here.

FYI, here's the code of my integration, i.e., a simple action that invokes my ZX Spectrum emulator and lets me type in the Output window:

package org.zx.spectrum;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.netbeans.api.extexecution.ExecutionDescriptor;
import org.netbeans.api.extexecution.ExecutionService;
import org.netbeans.api.extexecution.ExternalProcessBuilder;
import org.netbeans.api.options.OptionsDisplayer;
import org.openide.util.Exceptions;
import org.openide.util.RequestProcessor;

public final class ZXSpectrumAction implements ActionListener, Runnable {

    public void actionPerformed(ActionEvent e) {

    public Integer execute() {
        try {
            ExecutionDescriptor descriptor = new ExecutionDescriptor().
                    optionsPath(OptionsDisplayer.ADVANCED + "/org-zx-spectrum-ZXSpectrumGamesAdvancedOption").
            ExecutionService executionService = ExecutionService.newService(new ExternalProcessBuilder("xspect"), descriptor, "xspect command");
            Future<Integer> task = executionService.run();
            return task.get();
        } catch (InterruptedException ex) {
        } catch (ExecutionException ex) {
        return null;

    public void run() {

Maybe not the best code, but good enough for me to play my favorite games with. Would be awesome of course if I could grab those dialogs and integrate them as TopComponents into the IDE. But I doubt that that is possible, I certainly spent some time trying to find a way of doing so.


Get the open source Atomist Software Delivery Machine and start automating your delivery right there on your own laptop, today!


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}