Wednesday, May 8, 2013

Customizing JDeveloper Preferences

I like to tweak some of the preferences in the Tools menu of JDeveloper. I thought I would document them here for my own reference and in case anyone else is interested. I'll try to list all the settings I typically change from their default. These are ordered and grouped by their panels in the preferences dialog so you should be able to locate them easily.

  • Environment
    • Line Terminator to "Line Feed (Unix/Mac)" especially if you are in a mixed environment with windows and linux/mac developers as it prevents a lot of problems if everyone creates the files in the same way.
    • Encoding to "UTF-8". I have no idea why the default is platform dependent (MacRoman or some obscure windows code page). I like all developers in the team to use the same encoding. This is also used as encoding in XML files you create. Changing it afterwards can be a lot more work as existing files might need recoding
  • Environment > Log
    • Maximum Log Lines to something like 50000. The default of 3000 can be too small if you crank up the logging levels in a development session.
  • ADF Business Components
    • Look at all these settings carefully (and read below). Lots of these settings are used when creating new ADF BC objects so be careful to set these up before you start developing as it can safe a lot of rework later
  • ADF Business Components > Base Classes
    • You can set the default base classes for any ADF BC object you will create in JDeveloper. It is wise to create company wide extension classes for these and configure JDeveloper to use your company extended classes instead of the JDeveloper base ones. You could even  create a layer of extension classes for your project (extending from company classes) and setup the per-project settings to use these application level extension classes
  • ADF Business Components > Packages
    • A lot of developers like to group their ADF BC objects per type in separate sub packages. For instance put all view objects in a subpackage .views or .queries. In stead of remembering to set these sub packages each time you are creating ADF BC objects simply set the defaults here.
  • ADF Business Components > View Objects
    • You could set the default fetching tuning parameters for new view objects here. But in reality they need consideration for each view object you create. One trick we used in the past is to set a ridiculous default value here and then check for that ridiculous value in your extended ADF ViewObject classes. If the developer left the ridiculous initial value simply throw an exception telling the developer to set reasonable values.
  • Audit
    • The JDeveloper Audit framework is under-appreciated. I would advise to tweak the Code Assist Rules that you see while developing. Go over the rules that are disabled by default and see if you want to enable them. My guess is you can enable most of them, especially to warn developers about missing or incorrect javadoc. Also be sure to check the "Audit During Compile" with perhaps a slightly less restrictive set to prevent your developers from violating certain rules. The next step would be to monitor these quality issues from your continuous build server
  • Code Editor
    • I like to enable "Reformat Code Block When Pasting". That is mainly since I tend to keep most of my code auto-formatted so reformatting when pasting someone else's code seems like a good idea.
    • One other thing I like to enable is "Show Total Number of Lines in the Status Bar" just to remind to keep the files small and simple.
  • Code Editor > Code Templates
    • You can add your own code templates here. We've added a bunch to easily use ADFLogger in your Java source code. More on that in a future post.
  • Code Editor > Display
    • Enable Text Anti-Aliasing because it just looks better :-)
  • Code Editor > Line Gutter
    • Enable "Show Line Numbers"
  • Code Editor > Save Actions
    • These are actions that JDeveloper should perform on each file you save. I typically add "Organize Imports", "Trim Trailing Whitespace" and "Clear All Highlighting". I've tried using Reformat as well which is great for Java sources which should always be formatted by a tool for consistency. But JDeveloper will then also reformat all XML files including JSF pages. In those files it is much more common to perform manual formatting and I don't like the always-auto-format of these save actions.
  • Compiler
    • Enable "Clean Project Before Project Rebuild". If you are rebuilding your entire project I see no reason why you don't want to start with a clean project first. Otherwise you might run the risk of keeping compiled artifacts for source objects you have already removed.
  • CSS Editor
    • If you do anything with ADF skinning be sure to set the CSS level to Level 3 (and on JDev 11gR1) enable the ADF Faces Extensions checkbox
  • Debugger
    • Check "Show Action Buttons" to get the debugger buttons (step, continue, etc) also in the log window of JDeveloper.
  • Debugger > Beakpoints
    • Set the scope for new breakpoints to Global. Especially if you are building on a large system with multiple workspaces. With the default setting your debugger will not stop if you set a breakpoint in one workspace and run the application from another workspace. My workflow is to keep the number of breakpoints limited and I frequently clean them. I would like the confidence that a breakpoint is always used.
  • Debugger > Data
    • I personally don't like the new Tree View in the 11gR2/12c debugger where you drill down into objects and have to traverse back up. I prefer the old-style Table View so I change the default view here.
  • Debugger > Smart Data
    • I like to increase the "Number of Lines to Analyze" to something like 5 to show a bit more information in this debugger panel.
    • I personally don't like the new Tree View in the 11gR2/12c debugger where you drill down into objects and have to traverse back up. I prefer the old-style Table View so I change the default view here.
  • Debugger > Watches
    • I personally don't like the new Tree View in the 11gR2/12c debugger where you drill down into objects and have to traverse back up. I prefer the old-style Table View so I change the default view here.
  • File Types
    • I like to change the default editor panel used for certain files. I don't like JSF files to open in design WYSIWYG mode as initializing that editor can be slow. I prefer these to start in source view and I can always switch to the design tab if needed. You can set this in the Default Editors tab of these preferences. I like to set this to "Source" for "ADF Fragment File", "HTML Source", "HTML Template", "JSFF Label", "JSP Segment", "JSP Source", "XHTML/Facelets Source" and "XHTML Source" (not all of these exist in every version of JDeveloper)
  • News (JDev 12c only)
    • Add http://feeds.feedburner.com/RedHeap to the list of News Feeds to get Red Heap posts in JDeveloper :-)
  • Run > WebLogic
    • On 11gR2 only enable FastSwap deployment to you can make more changes to a deployed application without doing a full redeploy. Unfortunately this feature is not available on 11gR1.
  • Web Browser and Proxy
    • If your organisation uses a web proxy be sure to fill in these details so JDeveloper can access the internet for things like checking for updates. You can also set you default web browser here in case that is different from the default browser of your operating system. I like to use Google Chrome as my development browser and sometimes you cannot change the default web browser of your operating system due to administrator restrictions.
    • When using Chrome as your browser be sure to start it in incognito mode. This ensures you start with a clean browser each time you start your application. In JDeveloper 11g you can simply add --incognito to the command line of chrome while JDeveloper 12c allows you to specify --incognito ${URL} as command line parameters.
Some other things I would like to chance with a default JDeveloper installation:

  • Select Tools > External Tools and let JDeveloper create the default external tools when running on Microsoft Windows. This gives you a convenient right-click on all your objects to start a windows explorer in that specific source directory. Something I frequently use, for example to get access to TortoiseSVN on that file. On Mac I like to setup this to run a terminal from the selected directory.
  • Change the memory options in JDEV_HOME/ide/bin/ide.conf. On a 32-bit JVM I like to set both -Xmx and -Xms to 1200M. On a 64-bit JVM you could even go a bit higher, like 1500M or 2000M.
  • When running with non-English regional settings on your operating system, edit JDEV_USER_HOME/system11.x.x.x.x.x.x/DefaultDomain/bin/setDomainEnv.cmd, search for the lines where EXTRA_JAVA_PROPERTIES are set and add a line
    set EXTRA_JAVA_PROPERTIES=-Duser.language=en -Duser.country=US %EXTRA_JAVA_PROPERTIES%
    This enforces WebLogic to use en_US as locale so error messages in the JDeveloper Log window are English and not the language from your operating system. This makes googling for these error messages much easier ;-)
  • While you're already editing JDEV_USER_HOME/system11.x.x.x.x.x.x/DefaultDomain/bin/setDomainEnv.cmd you might just as well increase the memory for WebLogic. Search for the lines where XMS_SUN_64BIT, XMS_SUN_32BIT, XMX_SUN_64BIT and XMX_SUN_32BIT are set. My advice is to change all four to 1024 but you might want to tweak this for your situation.
    When using JDeveloper 12.1.2 you can set memory arguments in JDEV_USER_HOME/system12.1.2.x.x.x.x/DefaultDomain/bin/setStartupEnv.cmd in the section for AdminServerStartupGroup.

11 comments:

  1. Hi Wilfred, nice post.
    One small remark regarding:
    "
    Run > WebLogic
    On 11gR2 only enable FastSwap deployment to you can make more changes to a deployed application without doing a full redeploy. Unfortunately this feature is not available on 11gR1
    "

    Actually such option exists out-of-the-box in 11gR1, when running Integrated Weblogic in Debug Mode only.

    Thank you,

    Florin

    ReplyDelete
    Replies
    1. As far as I know 11gR1 only has support for the normal class redefinition that's part of the JDK. That only allows for very minor changes to a class and no changes in the signature of the class or methods. FastSwap allows for many more changes without redeploying your application. See http://docs.oracle.com/cd/E12840_01/wls/docs103/deployment/deployunits.html#wp1053872 for supported changes and remaining limitations

      Delete
    2. HotSwap, FastSwap, JPDA Debug - this is getting confusing, but nevertheless interesting.

      I agree, entirely : First JDeveloper integration with FastSwap came out with 11gR2. However, FastSwap has been around for a while - 2008 more exactly, since the release of Weblogic 10.3 . It can be enabled for any web application deployed on Weblogic by setting "fast-swap" element in weblogic.xml, therefore it would work for an ADF application running in Integrated WLS:

      http://technology.amis.nl/2009/06/26/fast-swap-in-weblogic-103-and-jdeveloper-11g-redeploy-after-compile-in-running-application


      Since we are diving into productivity topic, it worth mentioning that there is something equally important that 11gR2 brings: ability to change your ADF XML files (EO's, VO's, PageDefs without redeployment):

      http://docs.oracle.com/cd/E16162_01/web.1112/e16182/web_testdebug.htm#ADFFD23078

      Thank you,
      Florin







      Delete
  2. Nice sugestion:

    EXTRA_JAVA_PROPERTIES=-Duser.language=en -Duser.country=US %EXTRA_JAVA_PROPERTIES%"

    technical stuff should remain in English, always.

    ReplyDelete
  3. Hi Wilfred,

    Do you know if there is an option to change the Heap Size for the Business Component Browser (Application Module Tester) in JDev? This is not the Heap Size for JDev, but just the Heap Size for the Business Component Browser...

    Thanks

    P.S. Your blog came up in my search results for "heap size" :)

    ReplyDelete
    Replies
    1. Sure, simply edit the Model project properties, go to Run/Debug/Profile and edit the profile you are using. Then go to Launch Settings and add -Xmx1G to the Java Options or any other max memory limit you want to set

      Delete
  4. I've got another one, which might be useful:
    * Versioning > General
    When you're using TortioseSVN version 1.7 or higher, deselect "Use Navigator State Overlay Icons" and "Use Navigator State Overlay Labels" so JDeveloper doesn't crash on opening sources which are under svn control.

    ReplyDelete
    Replies
    1. That's a good one. I typically disable versioning support completely in JDev and just do it outside of JDeveloper

      Delete

Comments might be held for moderation. Be sure to enable the "Notify me" checkbox so you get an email when the comment is accepted and I reply.