<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>lekkimworld.com - Java category</title>
  <link>http://lekkimworld.com/categories/java/</link>
  <description>a blog about lotus notes, domino, sametime, expeditor and a whole lot of java...</description>
  <language>en</language>
  <copyright>Mikkel Heisterberg (mh [at] intravision [dot] dk</copyright>
  <lastBuildDate>Wed, 01 Jul 2009 21:13:46 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>lekkimworld.com (Java category)</title>
    <link>http://lekkimworld.com/</link>
  </image>
  
  
  <item>
    <title>Custom plug-in builds in Eclipse</title>
    <link>http://lekkimworld.com/2009/07/01/custom_plug_in_builds_in_eclipse.html</link>
    
      
        <description>
          &lt;p&gt;
Just had an interesting issue where I needed to make sure my Eclipse plug-in had the latest version of a jar-file I build in another Java project. Normally including a jar-file in a plug-in project is easy enough but when doing that you&#039;re normally using a static jar-file that doesn&#039;t change. I needed my plug-in to use the latest jar from the other Java project whenever the plug-in was built. Hmmm....
&lt;/p&gt;
&lt;p&gt;
After some searching around and some hints via Twitter I found the solution and it was very easy as Eclipse already include the plumbing for this (from Eclipse 3.2). The solution was to contribute custom build steps to the build.xml that the PDE in Eclipse auto-generates. It&#039;s way easier than it sounds.
&lt;/p&gt;
&lt;p&gt;
The only changes I needed to make to my plug-in project was to:
&lt;ul&gt;
&lt;li&gt;Add &#034;customBuildCallbacks=customBuildCallbacks.xml&#034; to the build.properties&lt;/li&gt;
&lt;li&gt;Add a customBuildCallbacks.xml Ant file to my plug-in project (the one that needed the newest jar) with a single target called &#034;pre.gather.bin.parts&#034;&lt;/li&gt;
&lt;li&gt;Write &#034;code&#034; for the target that replaces the jar-file in my plug-in project with the one from my Java project&lt;/li&gt;
&lt;li&gt;Build the plug-in via my update site&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;
For full details refer to &lt;a href=&#034;http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.pde.doc.user/tasks/pde_custom_callbacks.htm&#034;&gt;Plug-in Development Environment Guide/Tasks/PDE Build Advanced Topics/Feature and Plug-in custom build steps&lt;/a&gt; in the online help.
&lt;/p&gt;
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/07/01/custom_plug_in_builds_in_eclipse.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/07/01/custom_plug_in_builds_in_eclipse.html</guid>
    <pubDate>Wed, 01 Jul 2009 21:13:46 GMT</pubDate>
  </item>
  
  <item>
    <title>Generating unique id&#039;s for Notes widgets</title>
    <link>http://lekkimworld.com/2009/06/21/generating_unique_ids_for_notes_widgets.html</link>
    
      
        <description>
          &lt;p&gt;
If you write code to automatically generate widget descriptors (aka extension.xml) for users you have to ensure that the widget id is unique. A nice exxample of this can be found &lt;a href=&#034;http://lekkimworld.com/2009/06/12/google_maps_widget_generator_come_grab_your_own.html&#034;&gt;here&lt;/a&gt;. One caveat is that the widget id is used to distinguish the widgets hence has to be unique. To easiest way to generate a unique id in Java is to use the &lt;a href=&#034;http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html&#034;&gt;java.util.UUID&lt;/a&gt; class. Generating a unique, random, id with this class is easy.
&lt;pre&gt;
String id = java.util.UUID.randomUUID().toString();
&lt;/pre&gt;
&lt;/p&gt;

        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/06/21/generating_unique_ids_for_notes_widgets.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/06/21/generating_unique_ids_for_notes_widgets.html</guid>
    <pubDate>Sun, 21 Jun 2009 08:39:40 GMT</pubDate>
  </item>
  
  <item>
    <title>Don&#039;t install Notes in the default location if doing Notes plug-in development</title>
    <link>http://lekkimworld.com/2009/06/17/dont_install_notes_in_the_default_location_if_doing_notes_plug_in_development.html</link>
    
      
        <description>
          &lt;p&gt;
A little while back I was contacted by a fellow Yellow-head who had some issues with some plug-in development for Notes 8. Unfortunately I wasn&#039;t able to help him at the time but when he some head scratching time later found the answer he was kind enough to share it. I thought I would share it here in case it can help someone. 
&lt;/p&gt;
&lt;p&gt;
From the offset the issue looked simple as it had to do with the good old nlsxbe which is normally caused by the binary Notes directory not being on the path. The issue was however a bit twisted as the error raised complained about the filename or extension being too long.
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;
java.lang.UnsatisfiedLinkError: nlsxbe 
   (The filename or extension is too long. )
&lt;/pre&gt;
&lt;/p&gt;
&lt;p&gt;
What our good Yellow-head found out was that the issue was caused by his install location of the Notes client. Specifically he had installed his client in &#034;C:\Archivos de programa\IBM\Lotus\Notes&#034; which is the default location for his OS. This however means that the path to the notes.jar for plug-ins becomes &#034;C:\Archivos de programa\IBM\Lotus\Notes\framework\rcp\eclipse\plugins\com.ibm.rcp.j2se.win32.x86_1.5.0.SR4-200707311521\jre\lib\Notes.jar&#034; which is too long a path (longer than 128 characters). Installing Notes in &#034;C:\program files\IBM\Lotus\Notes&#034; solved the issue. 
&lt;/p&gt;
&lt;p&gt;
So if you run into weird issues like this check your install path or choose an English copy of Windows! :-)
&lt;/p&gt;

        </description>
      
      
    
    
    
    <category>Java</category>
    
    <category>IBM</category>
    
    <comments>http://lekkimworld.com/2009/06/17/dont_install_notes_in_the_default_location_if_doing_notes_plug_in_development.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/06/17/dont_install_notes_in_the_default_location_if_doing_notes_plug_in_development.html</guid>
    <pubDate>Wed, 17 Jun 2009 13:07:58 GMT</pubDate>
  </item>
  
  <item>
    <title>By popular demand - scaling images in Java for Lotus Connections</title>
    <link>http://lekkimworld.com/2009/04/29/by_popular_demand_scaling_images_in_java_for_lotus_connections.html</link>
    
      
        <description>
          &lt;p&gt;
After blogging about how &lt;a href=&#034;http://lekkimworld.com/2009/04/16/lotus_connections_teaches_you_how_to_scale_images_in_java.html&#034;&gt;Lotus Connetions teaches you to scale images in Java&lt;/a&gt; the other day I was contacted by Lotus Support who really would like to see the code as customers were asking for such code. &lt;a href=&#034;http://www.curiousmitch.com/&#034;&gt;Mitch&lt;/a&gt; also forwarded me a response from Lotus Support where they referred to my blog post which I got a real kick out of... :-)
&lt;/p&gt;
&lt;p&gt;
So here&#039;s the code. Thanks to the customer for allowing me to blog the code. Use to your hearts content but don&#039;t blame me if it doesn&#039;t work for you. The &lt;a href=&#034;http://lekkimworld.com/pages/disclaimer.html&#034;&gt;disclaimer&lt;/a&gt; is there for a reason.
&lt;/p&gt;
&lt;p&gt;
&lt;pre&gt;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOError;
import java.io.IOException;

import javax.imageio.ImageIO;

public class ScalePicture {
  
  public static void main(String[] args) {
    try {
      File f = new File(&#034;d:\\images&#034;);
      File pictSrc = new File(f, &#034;source_photo.jpg&#034;);
      File pictDest = new File(f, &#034;destination_photo.jpg&#034;);
      if (pictDest.exists()) {
        System.out.println(&#034;deleting...&#034;);
        pictDest.delete();
      }
      
      // scale image
      BufferedImage img = scaleImage(pictSrc);
      
      // write to target image
      ImageIO.write(img, &#034;jpg&#034;, pictDest);
      
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }
  
  private static BufferedImage scaleImage(File source) 
    throws IOException {
    // declarations
    final int width = 115;
    final int height = 115;
    
    // read source image
    BufferedImage imgSrc = ImageIO.read(source);
    
    // calculate scale factor
    double scaleFactor = (double)imgSrc.getWidth() / 
      (double)width;
    
    // scale image
    BufferedImage imgScaled = new BufferedImage((int)
      (scaleFactor * 100), height,
      BufferedImage.TYPE_INT_RGB);
    AffineTransform transform = AffineTransform.
      getScaleInstance(scaleFactor, scaleFactor);
    Graphics2D g = imgScaled.createGraphics();
    g.drawRenderedImage(imgSrc, transform);
    g.dispose();
    
    // create new target image in correct size 
    // with white background
    BufferedImage imgResized = new BufferedImage(width, 
      height, 
      BufferedImage.TYPE_INT_RGB);
    g = imgResized.createGraphics();
    g.setBackground(Color.WHITE);
    g.fillRect(0, 0, width, height);
    
    // calculate offset for scaled image on new image
    int xoffset = (int)((double)(width - imgScaled.getWidth()) / 
      (double)2);
    
    // draw scaled image on new image
    g.drawImage(imgScaled, xoffset, 0, null);
    g.dispose();
    
    // return new image
    return imgResized;
  }

}
&lt;/pre&gt;
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/04/29/by_popular_demand_scaling_images_in_java_for_lotus_connections.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/04/29/by_popular_demand_scaling_images_in_java_for_lotus_connections.html</guid>
    <pubDate>Wed, 29 Apr 2009 12:23:30 GMT</pubDate>
  </item>
  
  <item>
    <title>JavaPosse episode 245 on OSGi</title>
    <link>http://lekkimworld.com/2009/04/23/javaposse_episode_245_on_osgi.html</link>
    
      
        <description>
          &lt;p&gt;
I listened to the &lt;a href=&#034;http://javaposse.com/index.php?post_id=456475&#034;&gt;JavaPosse podcast episode 245&lt;/a&gt; today during my commute. The podcast was very interesting as it is an interview with &lt;a href=&#034;http://www.aqute.biz/Blog/HomePage&#034;&gt;Peter Kriens&lt;/a&gt; (of aQute) and &lt;a href=&#034;http://blog.bjhargrave.com/&#034;&gt;B.J. Hargrave&lt;/a&gt; (of IBM) the two specification leads on OSGi. OSGi off cause being the bundle management system of Eclipse and hence your most beloved Notes client. Worth a listen for sure.
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/04/23/javaposse_episode_245_on_osgi.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/04/23/javaposse_episode_245_on_osgi.html</guid>
    <pubDate>Thu, 23 Apr 2009 17:12:53 GMT</pubDate>
  </item>
  
  <item>
    <title>Lotus Connections teaches you how to scale images in Java</title>
    <link>http://lekkimworld.com/2009/04/16/lotus_connections_teaches_you_how_to_scale_images_in_java.html</link>
    
      
        <description>
          &lt;p&gt;
Lotus Connections is a little bit screwy when it comes to profile pictures IMHO as they are being forced to be square in Profiles (115x115 pixels). In profiles search results however they are scaled to 55 pixel in width and height is automatic...
&lt;/p&gt;
&lt;p&gt;
In my mind portrait pictures are rectangular and not square. 
&lt;/p&gt;
&lt;p&gt;
Yesterday this gave me some grief as I was at a customer where I had to write Java code to import pictures in the PHOTO table of the Lotus Connections PEOPLEDB database. The actual importing the pictures into the database is easy using JDBC but the pictures showed up wrongly in Lotus Connections as they were rectangular (200 x 133 pixels). They clearly had to be scaled but how - clearly not manually!
&lt;/p&gt;
&lt;p&gt;
As with many other things you are gifted with Java as it already contains all the pieces you need to scale pictures. I quickly found some &lt;a href=&#034;http://www.rgagnon.com/javadetails/java-0243.html&#034;&gt;sample code&lt;/a&gt; on Google to use java.awt for the resizing. The solution was to 
&lt;ol&gt;
&lt;li&gt;Scale the source image from 200 x 133 pixels to 115 x 76 pixels to keep the aspect ratio&lt;/li&gt;
&lt;li&gt;Create a new blank white image sized 115 x 115 pixels&lt;/li&gt;
&lt;li&gt;Place the resized source image on top of the white image centered&lt;/li&gt;
&lt;li&gt;Upload the resulting image to the database as a byte array&lt;/li&gt;
&lt;/ol&gt;
&lt;/p&gt;
&lt;p&gt;
Love Java!
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/04/16/lotus_connections_teaches_you_how_to_scale_images_in_java.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/04/16/lotus_connections_teaches_you_how_to_scale_images_in_java.html</guid>
    <pubDate>Thu, 16 Apr 2009 16:29:53 GMT</pubDate>
  </item>
  
  <item>
    <title>Eclipse match rules</title>
    <link>http://lekkimworld.com/2009/04/16/eclipse_match_rules.html</link>
    
      
        <description>
          &lt;p&gt;
From the Composite Application wiki comes a nice document on &lt;a href=&#034;http://www-10.lotus.com/ldd/compappwiki.nsf/dx/defining-feature-and-match-rules&#034;&gt;Defining feature and match rules&lt;/a&gt;. The difference between this an other such documents is that this one actually has some examples to illustrate the difference between Perfect, Equivalent, Compatible and greaterOrEqual.
&lt;/p&gt;
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <comments>http://lekkimworld.com/2009/04/16/eclipse_match_rules.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/04/16/eclipse_match_rules.html</guid>
    <pubDate>Thu, 16 Apr 2009 11:58:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Show &#039;n Tell Thursday: Configuring Ubuntu for Notes 8 plugin development (2 April 2009)</title>
    <link>http://lekkimworld.com/2009/04/02/show_n_tell_thursday_configuring_ubuntu_for_notes_8_plugin_development_2_april_2009.html</link>
    
      
        <description>
          &lt;p&gt;
&lt;img src=&#034;http://lekkimworld.com/images/domino/show-n-tell/showandtellthursdays_small.jpg&#034; style=&#034;float: right; margin: -10px 0 10px 10px;&#034; /&gt;
This weeks SnTT post is about configuring Eclipse on Ubuntu 8.0.4 for Notes plug-in development. I use Notes 8.5 but it should work equally well for Notes 8.0.x clients. Wan&#039;t to develop plug-ins? Well read on and do it on Ubuntu. Notes 8.x runs freakishly fast on Ubuntu. Read on...
&lt;/p&gt;
&lt;p&gt;
Actually this is a cheat post as the steps are almost the same as for doing it on Windows. Most of the stuff has to do with platform differences. My post for doing it on Windows is &lt;a href=&#034;http://lekkimworld.com/pages/eclipse34_notes85.html&#034;&gt;here&lt;/a&gt;. I have updated this guide with steps for Linux. Enjoy!!
&lt;/p&gt;

        </description>
      
      
    
    
    
    <category>Java</category>
    
    <category>SnTT</category>
    
    <comments>http://lekkimworld.com/2009/04/02/show_n_tell_thursday_configuring_ubuntu_for_notes_8_plugin_development_2_april_2009.html#comments</comments>
    <guid isPermaLink="true">http://lekkimworld.com/2009/04/02/show_n_tell_thursday_configuring_ubuntu_for_notes_8_plugin_development_2_april_2009.html</guid>
    <pubDate>Thu, 02 Apr 2009 12:29:16 GMT</pubDate>
  </item>
  
  </channel>
</rss>
