Bluej object Explained

The bluej object holds the interface that is exposed trough the Extension mechanism. All that is described in the extension mechanism can be done by means of this object.

As an example we can look at some javascript code that loads a project

In the following script it is assumed that there is a project called shapes in your local hard disk. It is not the scope of this tutorial to teach you how to create projects, we just assume that you have done it and the shapes project is located under c:/shapes

shapes = new ("c:/shapes");
bluej.openProject (shapes);

What should happen is that the shapes projects opens and you can then interact with it.

The following methods are the ones that you will be using as a script writer.

bluej.openProject (File)

This method opens the project identified by the given project File. An example of opening a project is given above.


Creates a new project using as location the given File. Note that File should point to a writable directory.


Returns an array of open projects. You can then look at each of them to display useful information. An example can be as follows:

   print ('----------------------- Project list\n');
   alist = bluej.getOpenProjects();
   for ( index=0; index < alist.length; index ++ )
      print ('-- Project name=',alist[index].getName(),'\n');


Returns the package being currently selected. Using the Extension API you can then look at some package properties like what classes are available or what is the package name. See the Extensions API.


Returns the frame currently selected. This is useful if some modal dialog is being used before a package is openend.

bluej.getSystemLibDir ()

Returns the path of the <BLUEJ_HOME>/lib system directory. This can be used to locate systemwide configuration files. Having the directory you can then locate a file within it.


Returns the path of the user configuration directory.
This can be used to locate user dependent information. Having the directory you can then locate a file within it.

bluej.getBlueJPropertyString (String property, String def)

Returns a property from BlueJ's properties or the default valu if the property is not found.

There are many more methods available into the bluej object. Look into the Extensions API for further information. You need to look at the extensions API in any case if you wish to create your own Objects using the Extensions API.