HOWTO: Debugging Amber Applications in JBuilder

The Amber Server is packaged as a JAR file. When developing Amber applications, you can add the AmberServer.jar file to your project as a library, and write and compile your code in the JBuilder IDE. The primary limitation of this approach is that it requires you to execute the Amber Server from outside JBuilder, using the command scripts provided in the Amber installation. Because of this, the Amber Server, and your Amber application, run in a non-JBuilder JVM, and thus the debugging features of JBuilder are not available.

Convincing JBuilder to execute the Amber Server inside the IDE is a simple matter of writing a small Java class that provides an entry point to the AmberServer. To do this, add the following java class to your project:

	  public class StartAmberServer
          public static void main(String args[])
            amber.server.manager.AmberServer.main(args) ; 
Because the StartAmberServer class above provides a main function, JBuilder will recognise it as a runnable class. You will be able to execute this class using the regular JBuilder "Run" and "Run with Debug" commands. The above code will invoke the AmberServer inside JBuilder, giving you full access to the IDE's debugging features.

Before the above code will work, you must have added the AmberServer.jar file to your classpath. Do this using Libraries tab in the Project Properties dialog box.

The current working directory is very important. If the current working directory is not set to your <AmberInstallationDir>/amberserver, Amber will not be able to find it's configuration files, and will abort with a "License Key not found" exception.

Those of you with JBuilder 5 or later have it easy - just set the Working Directory in the project properties.

For earlier versions of JBuilder, this option does not exist, and you have two options:

  1. Copy the config directory (and subdirectories) into the directory Amber is running out of. Amber reports it's working directory on the console when it starts up. For instance, if Amber is running out of \myprojects, you want to copy your Amber configuration directory into this directory, giving you a \myprojects\config directory, with miscellaneous subdirectories. Use this option only as a last resort, because it's very, very ugly.
  2. Create your StartAmberServer class (see above) in the <AmberInstallationDir>/amberserver directory. Run it out of here. Make sure that your StartAmberServer file has no package specifier. This works fine with JBuilder 3, because this version of JBuilder uses the location of the runnable file as the working directory. Other versions of JBuilder may not follow this convention.