Starting SqlDeveloper from an Ant Script

After a few brief detours, I’ve just started to develop extensions for SqlDeveloper again and found this useful. If you start SqlDeveloper from a desktop icon or menu item, the application starts normally. However, if you open a command prompt, and start the application ‘manually’ (sqldeveloper.exe) the application may spit out useful information to the console, such as “Could not load your extension because you’re a dork.”

Compiling an extension, putting it in a jar and deploying to the SqlDeveloper folder can be tedious so of course you would use Ant. I use Ant from Eclipse. Ant allows you to start an executable from the Ant script and in doing so, it acts as if it’s being run from the console and spits out SqlDeveloper messages to the Eclipse console…. Therefore, for example, you will be able to see any System.out.println(“ …….”) messages. Very useful.

Here’s a sample section of the Ant script:

<property name="sqldeveloper" location="C:/Program Files/Oracle Sql Developer 1.2/sqldeveloper.exe" />

<target name="run" depends="deployToSqlDeveloper">
  <echo>Opening SqlDeveloper at: ${sqldeveloper}</echo>
  <exec executable="${sqldeveloper}">
  </exec>
</target>

If you want to see SqlDeveloper logging messages, you must modify a config file. The config file should be located somewhere around here:

    ..\Oracle Sql Developer 1.5\sqldeveloper\bin\sqldeveloper.conf

Change the last line in the sqldeveloper.conf file :

    from: IncludeConfFile sqldeveloper-nondebug.conf
    to:   IncludeConfFile sqldeveloper-debug.conf

Once all this is done, you should see all kinds of 'stuff' in the Log pane.  If you don't, then click:

    View > Log

LoggingPane  

I think previously you may have had to start SqlDeveloper from the command line:

    sqldeveloper -J-Dide.extension.log.to.console=true

...but this no longer appears to be the case since version 1.5.

To run in debug mode, add an arg element to the exec element:

<target name="run" depends="deployToSqlDeveloper">
  <echo>Opening SqlDeveloper at: ${sqldeveloper}</echo>
  <exec executable="${sqldeveloper}">
    <arg value="debug">
  </exec>
</target>

When the Ant script is run you should see something similar to the following in the console:

    [exec] *** Port is 4000 ***
    [exec] *** Waiting for JPDA debugger connection

The port number will be necessary when you set up a debug project:

Click Run > Open Debug Dialog...

Double-click the Remote Java Application node on the tree to open up an editor with three tabs: Connect, Source and Common.

On the Connect tab, browse for the Project you're debugging. Enter a Name for the debug configuration, ensure the Port number is, for example 4000, and finaly click the debug button.

5/2/2008 | Comments (0) in SqlDeveloper
Email

Related posts