How to Create a Simple Console App


I have a simple Windows/Linux console application that I would like to retrofit with a couple of windows for displaying images during data processing. I’d prefer to not have to change the existing code to add support for the JUCE framework, i.e START_JUCE_APPLICATION, etc.

With the use of initialiseJuce_GUI/shutdownJuce_GUI, should I be able to do this?

For example, should the following test code actually work?

class TestWindow: public DocumentWindow
TestWindow( Image* image = NULL)
: DocumentWindow (T(“TestWindow”),
//setContentComponent (new ImageComponent( image ));

    setVisible (true);

    // centre the window on the desktop with this size
    centreWithSize( 400, 200 );


int main(int, char**)

File file( filename );
if( !file.exists() )
	return false;

FileInputStream stream( file );

ImageFileFormat* format = ImageFileFormat::findImageFormatForStream( stream );
if( NULL == format )
	return false; // no decoder found

Image* image = format->decodeImage( stream );
if( NULL == image )
	return false; // failed to decode

TestWindow* wnd = new TestWindow( image );


return 0;



…well no, that won’t work. If you’re running a GUI app, you need to run an event loop - it’s a completely different sort of beast to a console app. It’s possible to hack a console app to do it, but that’d be doing things the hard way, compared with just making a new project for it.