By John 'Jb' Brock-Oracle on Oct 13, 2011
It recently came to my attention, that while I've talked about it many times in the different posts on this blog, I've never written a post just about getting started with your first JDev extension.
Sorry about that!
So here I will finally correct that. I'm going to quickly cover the basics of starting an extension project from scratch and then how to run it from the IDE, and how to debug it from the IDE. I'll toss in NOTES when there is a difference between the R1 process and the R2 process. Most of it is still the same between versions of the IDE
To keep this at the beginners level: R1 refers to any version of the IDE that is 11.1.1.x where R2 is referring to anything 11.1.2.x and higher. You can read the post about migrating extensions from R1 to R2 to get some details about what is different in the newest release of the IDE.
Creating a new Extension Application and Project
There isn't a specific Extension Application selection when you go to the New Gallery and click on Applications. You will need to create a Generic (R1) or a Custom (R2) Application.
Double-Click on the application item to start the wizard.
Just enter the Application name and click on the Finish button at the bottom of the dialog.
The wizard will create a default project called "project1". Right-click on the project name and select "Delete Project".
You should select the option to remove the project and all of it's contents so we don't have junk code laying around in your work folder. We don't need this default project, as we will create our own extension project next.
Right-click in the empty space of the Application Navigator and select "New Project from the context menu.
Click on the Extension Development option under the Client Tier category, and then double-click on the "Extension Project" option.
Once the project creation wizard comes up, fill out the name of the Project with some thing that you like.
Give your project an identifier. This is what will be used in your library path.
The rest will be filled in for you with the information that you gave in the two entries above.
After the project is created, your IDE screen should look similar to this
Running the Extension
Now that we have our project created we can start work doing all of the things that I've already written blog posts about. For the sake of making this post only about Writing, Running, and Debugging, I'm going to just paste in some code and jump ahead to how to run the code from within the IDE.
After the project is saved and built(compiled) you can right-click on the project name in the Application Navigator and select "Run Extension". This will start another instance of the IDE with your extension loaded so you can see how it works.
NOTE: In 11gR2 you must click on the "Deploy to Target Platform" menu item before you Run or Debug the project. This is required to setup the MANIFEST.MF file with any changes that you may have made to your code, and then package everything up properly. This is not required for the 11gR1 version of the IDE.
Any error messages or warnings that occur during the running of the extension, will show up in the log window of the Parent IDE. This includes any System.out.* commands that you may have put into your code.
Debugging the Extension
You can set breakpoints in the code just like you would for any other type of code. To debug your extension, save the project, then right-click on the project name in the Navigator and select the "Debug Extension" option. The new instance of the IDE will start up, and you can perform the functions of your extension in that test instance.
NOTE: The same thing applies for Debugging as Running in 11gR2. You must click on the "Deploy to Target Platform" option before you click on the Debug menu item each time.
When the debugger hits a breakpoint in the code, the Parent instance of the IDE will show all of the debug info.
As you can see, it's pretty simple to run and debug you extension directly from the IDE. There isn't a need to save off the extension .jar file to the extension folder and restart the IDE like a lot of people have been doing. I hope this helps speed up development for people, and makes extension development just a little bit smoother for everyone.
As always, please post comments or questions so all developers can learn from each other.