<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Johan Känngård &#187; Java</title>
	<atom:link href="http://johankanngard.net/category/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://johankanngard.net</link>
	<description>Useful tips for developers</description>
	<lastBuildDate>Fri, 06 Aug 2010 13:49:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Managing logging with Log4j and Chainsaw</title>
		<link>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/</link>
		<comments>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 11:52:32 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Log4j]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/</guid>
		<description><![CDATA[Those of you who haven&#8217;t used System.out.println(&#8220;My variable: &#8221; + myVariable) in some Java classes to get debug information to the console, raise your hands please. None? ;-) I am very fond of logging as a complement to debugging, since I can &#8220;trace&#8221; actions in my programs even if the classes is in production. &#8220;But [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you who haven&#8217;t used System.out.println(&#8220;My variable: &#8221; + myVariable) in some Java classes to get debug information to the console, raise your hands please. None? ;-)</p>
<p>I am very fond of logging as a complement to debugging, since I can &#8220;trace&#8221; actions in my programs even if the classes is in production. &#8220;But hey, logging makes the application go slower!&#8221; you might think. Well, it&#8217;s up to you to decide, a small performance hit is likely to occur, a big hit if you don&#8217;t read the documentation of for instance the <a href="http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html">PatternLayout</a>.<br />
I use <a href="http://logging.apache.org/log4j">Log4j</a> a lot in the Java code I design and write, and haven&#8217;t noticed any big difference between logging and not logging.<br />
So, you might have used Log4j a bit and used <a href="http://logging.apache.org/log4j/docs/chainsaw.html">Chainsaw</a> to look at Log4j logging files. Why not look at the logging in realtime? Here is how to do it.<br />
<span id="more-126"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-8220767383302774";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Setting up Log4j</h2>
<p>To see the logging in real time, I use an appender called SocketHubAppender that acts as a server. Create the log4j.xml in the root of your Java application&#8217;s directory, or add the vital bits to your own:<br />
<code><br />
< ?xml version=\"1.0\" encoding=\"UTF-8\" ?><br />
< !DOCTYPE log4j:configuration SYSTEM \"log4j.dtd\"><br />
<log4j :configuration xmlns:log4j=\'http://jakarta.apache.org/log4j/\'<br />
	debug=\"true\"><br />
	<appender name=\"SOCKET\"<br />
		class=\"org.apache.log4j.net.SocketHubAppender\"></p>
<param name=\"port\" value=\"1020\" />
	</appender><br />
	<root></p>
<priority value=\"debug\" />
		<appender -ref ref=\"SOCKET\" /><br />
	</root><br />
</log4j></p>
<p><root></p>
<priority value=\"debug\" />
	<appender -ref ref=\"SOCKET\" /><br />
</root></p>
<p></code></p>
<p>When starting your application and outputs some logging messages with the usual logger.debug(&#8220;Hello world!&#8221;); it will be sent to the appender&#8217;s socket, defined above as 1020. The output can&#8217;t be read using a telnet session, because the things you will see is the logging events serialized&#8230; You need something to look at those serialized logging events with &#8211; Chainsaw!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8220767383302774";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Configure Chainsaw</h2>
<p>Create a file (or add the vital bits below to your own&#8230;) called chainsaw-config.xml somewhere on your local disk, for instance c:\temp\chainsaw-config.xml, and change the host from my.remote.host.net to the host where you set up the logging with the SocketHubAppender and that the port matches the one you used:<br />
<code><br />
< ?xml version=\"1.0\" encoding=\"UTF-8\" ?><br />
< !DOCTYPE log4j:configuration ><br />
<!-- Chainsaw receiver configuration--><br />
<log4j :configuration xmlns:log4j=\"http://jakarta.apache.org/log4j/\" debug=\"true\"></p>
<plugin name=\"MyRemoteLogging\" class=\"org.apache.log4j.net.SocketHubReceiver\">
<param name=\"Port\" value=\"1020\"/>
<param name=\"Host\" value=\"my.remote.host.net\"/>
   </plugin>
<p>   <root><br />
      <level value=\"debug\"/><br />
   </root><br />
</log4j><br />
</code><br />
<a href="http://logging.apache.org/log4j/docs/webstart/chainsaw/chainsawWebStart.jnlp">Start Chainsaw</a> via <a href="http://java.sun.com/products/javawebstart/">Java Web Start</a> by launching the jnlp-file at the <a href="http://logging.apache.org/log4j/docs/chainsaw.html">homepage</a>. Open the menu &#8220;View&#8221;, &#8220;Show Application-wide Preferences&#8221;, go to the &#8220;General&#8221; tab and enter &#8220;file://c:/temp/chainsaw-config.xml&#8221; (leave out the quotation marks) in the &#8220;Automatic Configuration URL&#8221; field, or whatever you named your config file. Click &#8220;OK&#8221; and restart Chainsaw. You should now see your receiver to the right named &#8220;MyRemoteLogging&#8221;.<br />
Try starting up your Java application and output some logging, and you will see them pop up directly in Chainsaw!</p>
<p>So why not use a simple file or database to log to? You can do that too, you are not limited to one appender per application. You can set up as many as you want, for instance a ConsoleAppender, a SocketHubAppender and a JDBCAppender that logs the events to all those targets.<br />
Log4j is powerful, but it doesn&#8217;t makes miracles if you don&#8217;t use some structured logging. Events like &#8220;Hello world!&#8221; is not going to help you, but some well designed NDC.push()&#8217;s and other will do good. And don&#8217;t forget to add the <a href="http://dev.kanngard.net/Permalinks/ID_20030210235410.html">NotesExceptionRenderer</a> to your class path, so that you get more info from those badly-designed exceptions :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>g33k date</title>
		<link>http://johankanngard.net/2007/05/25/g33k-date/</link>
		<comments>http://johankanngard.net/2007/05/25/g33k-date/#comments</comments>
		<pubDate>Fri, 25 May 2007 09:59:54 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2007/05/25/g33k-date/</guid>
		<description><![CDATA[I was a key speaker at the first g33k date ever yesterday, and it was Ekakan that held the meeting in their small but great office at SaltmÃ¤targatan in Stockholm. Quite a lot showed up, many of which I know by name, but not by face, since they are all bloggers with no pictures at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/kanngard/125357142/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/1/125357142_9c702152d7.jpg" width="500" height="281" alt="Johan defeating Darth Vader" style="float:none;" /></a><br />
I was a key speaker at the first g33k date ever yesterday, and it was <a href="http://ekakan.com/g33k">Ekakan</a> that held the meeting in their small but great office at SaltmÃ¤targatan in Stockholm. Quite a lot showed up, many of which I know by name, but not by face, since they are all bloggers with no pictures at their sites! :-) After having slurped down some well-known red-canned sugary liquid, I started my speech using <a href="http://www.openoffice.org">OpenOffice</a> Impress as presenter application. The slides can be found at the bottom of this post. It has not been cleaned up, so some references are to my local file system and applications on my Domino server will not work. I have put the database I used for the web service stuff as an attachment below, but use it at your own risk!<br />
I talked briefly about who I am, what I like, what my shoe size is and other important stuff. A short history on how the web has evolved over time (1.0, 1.5, 2.0) and my own suggestion of the next 3.0 level, which includes web services on the client side. I demonstrated a simple AJAX solution for typeahead with script.aculo.us and Domino and a web service consumer in the browser.<br />
A Midlet with a web service consumer was the next item to show, and it worked as a charm in the emulator!<br />
After my 15 minutes of fame (or rather 40), we had a short drinking and chatting pause.</p>
<p><a href="http://domino.dagerot.com/">Joachim Dagerot</a> introduced us into <a href="http://extjs.com">ext.js</a>, a client-side framework with lot&#8217;s of goodies like menus, trees, tabbed tables, layouts etc. The framework looked really impressive, and applications based on it was more of a Windows experience. When developing applications with ext.js, almost everything is done in JavaScript, including the templates of the pages. You don&#8217;t have to download the complete framework, you can <a href="http://extjs.com/products/extjs/build/">take bits and pieces</a>, if you want only a part of the gadgets.</p>
<p>After more beverages, snacks and more chatting, connections were made, business cards and email addresses exchanged hands. I left rather early though, I hope my fellow bloggers to give the full story ;-) Photos were taking during the meeting, and I would really love to see them, since I didn&#8217;t use my own camera.</p>
<p>I hope that this event wasn&#8217;t the last of it&#8217;s kind in Sweden, it was great fun to see fellow bloggers and geeks!<br />
Thanks for a great event everyone, especially <a href="http://ekakan.com">Ekakan</a> who arranged the g33k date!!</p>
<p>Btw, the picture at the top is NOT from the g33k date, it was just a picture I used in the presentation as an illustration of the thin red line between being a geek and a nerd. :-D</p>
<ul>
<li><a href="/wp-content/uploads/2007/05/g33kdate001.pdf" title="g33k date presentation">g33k date presentation</a></li>
<li><a href="/wp-content/uploads/2007/05/g33kdate.zip" title="g33kdate.nsf zipped">g33kdate.nsf zipped</a></li>
<li><a href="http://eclipseme.org/">EclipseMe</a>, J2ME plug in for <a href="http://eclipse.org">Eclipse</a></li>
<li><a href="http://java.sun.com/products/sjwtoolkit/">Sun Java Wireless Toolkit</a></li>
<li><a href="http://www.geology.smu.edu/~dpa-www/robo/nbot/">nbot</a></li>
</ul>
<p>[tags]g33k, geek, J2ME, AJAX, Webservice, Ekakan[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2007/05/25/g33k-date/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Sammanfattning av Lotusphere Comes To You</title>
		<link>http://johankanngard.net/2006/03/14/sammanfattning-av-lotusphere-comes-to-you/</link>
		<comments>http://johankanngard.net/2006/03/14/sammanfattning-av-lotusphere-comes-to-you/#comments</comments>
		<pubDate>Tue, 14 Mar 2006 13:21:42 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/03/14/sammanfattning-av-lotusphere-comes-to-you/</guid>
		<description><![CDATA[.inlineImageContainer {float:left; margin-right:10px;} H4 {padding-bottom:0px; margin-bottom:0px;clear:both;} P {margin-top:0px;padding-top:0px;} Detta Ã¤r i korthet vad som sades under halvdagen den 8:e mars i Kistam som IBM valt att kalla Lotusphere Comes to You. Presentationerna som visades finns att hÃ¤mta hos IBM. Inledningstal av Ed Brill Det var kul att se Ed Brill pÃ¥ hans fÃ¶rsta besÃ¶k i [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">.inlineImageContainer {float:left; margin-right:10px;} H4 {padding-bottom:0px; margin-bottom:0px;clear:both;} P {margin-top:0px;padding-top:0px;}</style>
<p>Detta Ã¤r i korthet vad som sades under halvdagen den 8:e mars i Kistam som <a href="http://www.ibm.com">IBM</a> valt att kalla <a href="http://www-5.ibm.com/se/news/events/lcty2006/index.html">Lotusphere Comes to You</a>. Presentationerna som visades finns att <a href="http://www-5.ibm.com/se/news/events/lcty2006/presentations.html">hÃ¤mta</a> hos IBM.</p>
<h4>Inledningstal av Ed Brill</h4>
<div class="inlineImageContainer" xstyle="float:left;"><a href="http://www.flickr.com/photos/kanngard/109798964/" title="Ed Brill"><img src="http://static.flickr.com/40/109798964_517a15f3f4_m.jpg" alt="Ed Brill" border="0" /></a></div>
<p>Det var kul att se <a href="http://www.edbrill.com">Ed Brill</a> pÃ¥ hans fÃ¶rsta besÃ¶k i Sverige!  Han presenterade siffror som visar att Lotusphere Ã¤r populÃ¤rare Ã¤n nÃ¥gonsin och att Notes knappast Ã¤r dÃ¶tt! Dessutom drog kort han igenom de nyheter som kommer framÃ¶ver, vilka presenterades i detalj av de svenska IBM-medarbetarna. FramfÃ¶randet var innehÃ¥llsrikt, men lite fÃ¶r kort. SjÃ¤lv hade jag inte mÃ¶jligheten att tala med honom, och jag hoppas att han Ã¥terkommer till Sverige vid ett senare tillfÃ¤lle!</p>
<h4>Notes pÃ¥ Linux</h4>
<div class="inlineImageContainer"><a href="http://www.flickr.com/photos/kanngard/109799031/" title="Karl Dettner"><img src="http://static.flickr.com/41/109799031_2521c4d4ce_m.jpg" alt="Karl Dettner" border="0" /></a></div>
<p>v.7.0.x av Notes kommer att gÃ¥ att kÃ¶ra pÃ¥ <a href="http://www.linux.org">Linux</a> via <a href="http://www-142.ibm.com/software/workplace/products/product5.nsf/wdocs/workplaceclienttech">Workplace Managed Client</a>. Karl Dettner demonstrerade detta LIVE genom att kÃ¶ra en fÃ¶nsterhanterare i Linux, och startade Notes samt surfade runt i databaser. Domino Designer kommer inte att kunna kÃ¶ras pÃ¥ Linux (Ã¤n), vilket gÃ¶r att man fortfarande Ã¤r hÃ¤nvisad till Windows alternativt <a href="http://www.winehq.com/" title="Wine">Wine</a>, en Ã¶ppen-kÃ¤llkodsimplementation av Windows API pÃ¥ Linux. Dock har det dykt upp ett fÃ¶rsÃ¶k till att skapa en <a href="http://www.timtripcony.com/blog.nsf/d6plinks/GUIN-6LQULQ">webbbaserad IDE</a> som liknar Domino Designer, vilket kan vara vÃ¤rt att bevaka.</p>
<h4>Notes pÃ¥ Mac</h4>
<p>Version <a href="http://www-10.lotus.com/ldd/r5fixlist.nsf/Progress/702">7.0.2</a> kommer att kunna kÃ¶ras pÃ¥ MacOS X. Domino Web Access i samma version kommer att stÃ¶dja <a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a> pÃ¥ <a href="http://www.apple.com/macosx/">MacOS X</a>, dock ej <a href="http://www.apple.com/macosx/features/safari/">Safari</a>.</p>
<h4>Notes 8 &#8220;Hannover&#8221;</h4>
<p><a href="http://www-306.ibm.com/software/swnews/swnews.nsf/n/nhan6dbjwg">8:an</a> bygger pÃ¥ <a href="http://www.eclipse.org">Eclipse</a> och kan dÃ¤rmed kÃ¶ras pÃ¥ ett flertal plattformar. Publik beta dyker upp i slutet av 2006. Alla befintliga Notesapplikationer kommer att fungera i Hannover (vilket upprepades som ett mantra ett flertal gÃ¥nger). Fokus pÃ¥ nÃ¥got som kallas aktiviteter, som Ã¤r en form av delprojekt i en arbetsgrupp. MÃ¶jlighet att spara/gruppera dokument, mail, chat etc. i aktiviteter fÃ¶r att senare kunna sÃ¶ka fram informationen. Markering av dokument sker genom att hela raden visas i annan fÃ¤rg, som Ã¤r standard i alla andra program pÃ¥ de flesta plattformar. Bockarna i kanten kommer sÃ¥ledes att fÃ¶rsvinna.<br />
Notesklienten kommer att kunna kÃ¶ra Webservices, Ã¤ven i lokala applikationer.</p>
<h4>Sametime 7.5</h4>
<div class="inlineImageContainer"><a href="http://www.flickr.com/photos/kanngard/109798985/" title="Anders Kjellner"><img src="http://static.flickr.com/47/109798985_5f392d9168_m.jpg" alt="Anders Kjellner" border="0" /></a></div>
<p>Anders Kjellner fÃ¶rklarade att Ã¤ven denna <a href="http://www-142.ibm.com/software/sw-lotus/products/product3.nsf/wdocs/sametimefuture">nya release</a> Ã¤r baserad pÃ¥ <a href="http://www.eclipse.org">Eclipse</a>, vilket mÃ¶jliggÃ¶r olika utseende i olika operativsystem, dvs. det ser ut som en MacOS-applikation pÃ¥ MacOS, och ser ut som en Windowsapplikation i Windows. Pluginarkitekturen frÃ¥n <a href="http://www.eclipse.org">Eclipse</a> gÃ¶r att tredjepartsutvecklare kan ta fram produkter fÃ¶r att utÃ¶ka funktionaliteten. Till en bÃ¶rjan finns t.ex. plugins fÃ¶r att koppla Sametime till videokonferensutrustning (<a href="http://www.tandberg.net/products/collaboration.jsp">Tandberg</a>) och IP-telefoni (<a href="http://avaya.com/gcm/master-usa/en-us/corporate/pressroom/pressreleases/2006/pr-060123.htm">Avaya</a>).<br />
Det bakomliggande nÃ¤tverksprotokollet Ã¤r fÃ¶rbÃ¤ttrat pÃ¥ mÃ¥nga punkter, bl.a. har mÃ¤ngden data som skickas minskats, samt att den anvÃ¤nder &#8220;intelligent&#8221; teknik fÃ¶r att hitta det mest optimala sÃ¤ttet att kommunicera med servern.<br />
NÃ¥gra anvÃ¤ndarnyheter Ã¤r bl.a. mÃ¶jligheten att anvÃ¤nda olika stilar pÃ¥ chattmeddelanden, stavningskontroll (endast engelska till att bÃ¶rja med), smileys, kunna skicka NoteslÃ¤nkar och historik som behÃ¥ller formattering. Positionsmedvetande gÃ¶r att Sametime kÃ¤nner av i vilket nÃ¤t du kopplat upp dig i, och frÃ¥gar efter den exakta adressen. Detta gÃ¶r att applikationen kan hjÃ¤lpa till med t.ex. val av rÃ¤tt skrivare, hitta rÃ¤tt till restauranger etc.<br />
Numera krÃ¤vs en <a href="http://en.wikipedia.org/wiki/Jvm">JVM</a> pÃ¥ minst 1.4 fÃ¶r att anvÃ¤nda Sametime, vilket betyder att Internet Explorers <a href="http://www.microsoft.com/mscorp/java/">MS JVM</a> inte kommer att fungera, utan man mÃ¥ste ladda ner &#8220;en annan&#8221;, fÃ¶rslagsvis <a href="http://www.java.com/en/download/manual.jsp">Suns</a>.</p>
<h4>Workplace Designer 2.6</h4>
<div class="inlineImageContainer"><a href="http://www.flickr.com/photos/kanngard/109799060/" title="Erik SÃ¶derholm"><img src="http://static.flickr.com/34/109799060_6a2606d5cf_m.jpg" alt="Erik SÃ¶derholm" border="0" /></a></div>
<p>UtvecklingsmiljÃ¶n fÃ¶r <a href="http://www-142.ibm.com/software/workplace/products/product5.nsf/wdocs/workplacehome">Workplace Collaborative Services</a>, <a href="http://www-128.ibm.com/developerworks/workplace/products/designer/">Workplace Designer</a>, Ã¤r vÃ¤ldigt likt <a href="http://www-142.ibm.com/software/sw-lotus/products/product4.nsf/wdocs/dominodesignerhome">Domino Designer</a>, och arbetssÃ¤ttet Ã¤r lika intuitivt och enkelt, men skiljer pÃ¥ nÃ¥gra punkter. Bl.a. har <acronym title="Workplace Designer">WD</acronym> stÃ¶d fÃ¶r dra-och-slÃ¤pp av element, exakt positionering och databasmodellering. FÃ¶r att gÃ¶ra livet Ã¤nnu enklare, anvÃ¤nder sig <acronym title="Workplace Designer">WD</acronym> av @funktioner i kod i t.ex. knappar. Alla @funktioner frÃ¥n Notes/Domino Ã¤r inte implementerade, men de mest basala. En inbyggd Java-brygga medger Ã¥tkomst av Javaobjekt och klasser pÃ¥ servern direkt frÃ¥n Javascript.</p>
<h4>Innovation Pack</h4>
<p>Ny funktionalitet till <a href="http://www-142.ibm.com/software/sw-lotus/products/product4.nsf/wdocs/whyupgrade">Notes och Domino 7</a> genom nya mallar/databaser, ingen uppdatering av koden i Notes/Domino. Dessutom en ny installation som tillÃ¥ter Notes att installeras pÃ¥ USB-minne (som dock kan gÃ¶ras idag men lite mer omstÃ¤ndligt). SlÃ¤pps under tredje kvartalet 2006.<br />
NÃ¥gra av mallarna som kommer att fÃ¶lja med:<br />
-<a href="http://en.wikipedia.org/wiki/Blog">Blog</a>, fÃ¶r att skapa en webblogg<br />
-<a href="http://en.wikipedia.org/wiki/RSS_%28file_format%29">RSS</a>, fÃ¶r att skapa RSS-flÃ¶den frÃ¥n befintliga databaser</p>
<h4>Bowstreet Portal Factory</h4>
<div class="inlineImageContainer"><a href="http://www.flickr.com/photos/kanngard/109799108" title="Patrik"><img src="http://static.flickr.com/45/109799108_7d38e2f60b_m.jpg" alt="Patrik" border="0" /></a></div>
<p><a href="http://www.bowstreet.com/">Bowstreet</a> <a href="http://www-306.ibm.com/software/swnews/swnews.nsf/n/nhan6jtrcu?OpenDocument&#038;Site=lotus">kÃ¶ptes av IBM</a> dÃ¥ produkten <a href="http://www.bowstreet.com/products/portletfactory/index.html">Portal Factory</a> var intressant. Den anvÃ¤nds fÃ¶r att bygga portlets utan att koda en enda rad, utan man fÃ¶ljer ett antal guider eller sÃ¥ kallade builders. <a href="http://www.bowstreet.com/products/portletfactory/index.html">Portal Factory</a> Ã¤r en plugin som kan anvÃ¤ndas i <a href="http://www-306.ibm.com/software/awdtools/developer/application/" title="Rational Application Developer for Websphere Software">RAD</a> eller <a href="http://www.eclipse.org">Eclipse</a>. I paketet ingÃ¥r 120 builders, som i bakgrunden skapar <a href="http://java.sun.com/javaee/index.jsp" title="Java Enterprise Edition">JEE</a>-kod. Denna kod kan sjÃ¤lvklart Ã¤ndras, men det behÃ¶vs ej, dÃ¥ i stort sett allt kan konfigureras. Patrik (antecknade ej efternamnet, tyvÃ¤rr&#8230;) visade ett exempel genom att anvÃ¤nda builders fÃ¶r Dominovyer och formulÃ¤r, fÃ¶r att hÃ¤mta och visa information frÃ¥n Dominoapplikationer i en <a href="http://java.sun.com/javaee/index.jsp" title="Java Enterprise Edition">JEE</a>-applikation.<br />
Man behÃ¶ver inte anvÃ¤nda <a href="http://www-306.ibm.com/software/genservers/portal/">Portal Server</a> fÃ¶r att anvÃ¤nda de byggda applikationerna, utan man kan generera dessa fÃ¶r vanliga <a href="http://java.sun.com/javaee/index.jsp" title="Java Enterprise Edition">JEE</a>-servrar, som t.ex. <a href="http://tomcat.apache.org/">Apache Tomcat</a>, <a href="http://tomcat.apache.org/">Borland AppServer</a> och sjÃ¤lvklart <a href="http://www-306.ibm.com/software/webservers/appserv/was/">Websphere Application Server</a>.<br />
<a href="http://www.bowstreet.com/products/portletfactory/index.html">Portal Factory</a> Ã¤r Ã¤nnu inte paketerad med <a href="http://www.ibm.com">IBM</a>s namn, men kan redan idag kÃ¶pas. En inte allt fÃ¶r vÃ¥gad gissning Ã¤r att denna produkt kommer att integreras med <a href="http://www-306.ibm.com/software/awdtools/developer/application/" title="Rational Application Developer for Websphere Software">RAD</a> och fÃ¶rhoppningsvis paketeras med Domino!?!</p>
<h4>Till sist</h4>
<p>Lotusphere Comes to You Ã¤r ett bra initiativ av <a href="http://www.ibm.com">IBM</a>, vi Ã¤r mÃ¥nga som inte har mÃ¶jlighet att Ã¥ka Ã¶ver Atlanten fÃ¶r att nÃ¤rvara pÃ¥ <a href="http://www.ibm.com/software/sw-lotus/lotusphere">Lotusphere</a>, men Ã¤ndÃ¥ vill fÃ¥ information. Visst finns det mesta tillgÃ¤ngligt pÃ¥ nÃ¤tet, men det kan vara svÃ¥rt att skilja godbitarna frÃ¥n allt brus dÃ¤rute! GlÃ¶m inte att titta pÃ¥ <a href="http://www-5.ibm.com/se/news/events/lcty2006/presentations.html">presentationerna</a>, speciellt den som avhandlar <a href="ftp://ftp.software.ibm.com/software/emea/se/pres/se/LCX_2005.zip">Bowstreet</a>!</p>
<p><a href="http://www.flickr.com/photos/kanngard/115928407/" title="Gula boxningshandskar"><img src="http://static.flickr.com/43/115928407_dc49bb1bac_m.jpg" width="240" height="180" alt="Gula boxningshandskar" /></a><br />
Efter inlÃ¤mnad utvÃ¤rdering fick vi en nyckelring med de berÃ¶mda gula boxningshandskarna! :-)</p>
<p>[tags]Lotus Notes, Lotus Domino, Workplace, Bowstreet, RAD, Sametime, Hannover[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/03/14/sammanfattning-av-lotusphere-comes-to-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove characters in a Java String</title>
		<link>http://johankanngard.net/2006/03/06/remove-characters-in-a-java-string/</link>
		<comments>http://johankanngard.net/2006/03/06/remove-characters-in-a-java-string/#comments</comments>
		<pubDate>Mon, 06 Mar 2006 14:59:44 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/03/06/remove-characters-in-a-java-string/</guid>
		<description><![CDATA[Here is a simple method (actually two) for removing multiple characters from a String: /** * Removes the specified characters from the supplied String. * * @param s the String to remove characters in. * @param a the characters to remove from the supplied String. * @return the String stripped from all the supplied characters. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple method (actually two) for removing multiple characters from a String:<br />
<code><br />
/**<br />
 * Removes the specified characters from the supplied String.<br />
 *<br />
 * @param s the String to remove characters in.<br />
 * @param a the characters to remove from the supplied String.<br />
 * @return the String stripped from all the supplied characters.<br />
 */<br />
public static String removeChars(String s, char[] a) {<br />
	StringBuffer r = new StringBuffer();<br />
	for (int i = 0; i < s.length(); i ++) {<br />
		if (!contains(s.charAt(i), a)) {<br />
			r.append(s.charAt(i));<br />
		}<br />
	}<br />
	return r.toString();<br />
}</p>
<p>/**<br />
 * Searches a char array for the specified character.<br />
 *<br />
 * @param c the char to find in the char array.<br />
 * @param a the char array to search in.<br />
 * @return true if the char is found in the char array,<br />
 * false if not.<br />
 */<br />
public static boolean contains(char c, char[] a) {<br />
	for (int i = 0; i < a.length; i++) {<br />
		if (c == a[i]) {<br />
			return true;<br />
		}<br />
	}<br />
	return false;<br />
}<br />
</code><br />
<!--adsense#banner001--><br />
The above can be used like this to check if a String is a valid phone number:<br />
</code><code><br />
/**<br />
 * Checks if the String is a valid phone number.<br />
 * It is valid if it only contains numbers or any of the characters<br />
 * +-() and space<br />
 *<br />
 * @param s the String to test for a valid phone number.<br />
 * @return true if the supplied String is a valid phone number,<br />
 * false if not.<br />
 */<br />
public boolean isValidPhoneNumber(String s) {<br />
	char[] a = {'-', '+', '(', ')', ' '};</p>
<p>	try {<br />
		Double.parseDouble(removeChars(s, a));<br />
		return true;<br />
	} catch (NumberFormatException e) {<br />
		return false;<br />
	}<br />
}<br />
</code><br />
<a href="http://jakarta.apache.org/commons/lang/">Apache Jakarta Commons Lang</a> <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringUtils.html">StringUtils</a> has a variant of the removeChars method above called <a href="http://jakarta.apache.org/commons/lang/api/org/apache/commons/lang/StringUtils.html#replaceChars(java.lang.String,%20java.lang.String,%20java.lang.String)">replaceChars</a> that also can be useful.<br />
[tags]Java[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/03/06/remove-characters-in-a-java-string/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Echo XML from a file, String or InputStream in Java with SAX</title>
		<link>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/</link>
		<comments>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/#comments</comments>
		<pubDate>Mon, 13 Feb 2006 13:51:06 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/</guid>
		<description><![CDATA[Here is an example how to use the XMLEchoer class, that I have refurbished from Sun&#8217;s tutorial Echoing an XML File with the SAX Parser. It is of limited use, but can be a good start learning SAX. import java.io.PrintWriter; import lotus.domino.AgentBase; import net.kanngard.xml.XMLEchoer; public class JavaAgent extends AgentBase { public void NotesMain() { try [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example how to use the XMLEchoer class, that I have refurbished from <a href="http://www.sun.com">Sun&#8217;s</a> tutorial <a href="http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/2a_echo.html">Echoing an XML File with the SAX Parser</a>. It is of limited use, but can be a good start learning SAX.<br />
<code><br />
import java.io.PrintWriter;<br />
import lotus.domino.AgentBase;<br />
import net.kanngard.xml.XMLEchoer;</p>
<p>public class JavaAgent extends AgentBase {</p>
<p>    public void NotesMain() {</p>
<p>        try {<br />
            String xml = "<test>Hello World</test>";<br />
            PrintWriter writer = getAgentOutput();<br />
            writer.println("Content-type: text/xml");<br />
            XMLEchoer echoer = new XMLEchoer(writer);<br />
            echoer.start(xml);<br />
        } catch(Exception e) {<br />
            e.printStackTrace();<br />
        }<br />
    }<br />
}<br />
</code></p>
<p>To get it working, you need a SAX implementation, like <a href="http://xerces.apache.org/xerces2-j/">Apache Xerces 2</a>. Just drop the JAR files from Xerces 2 into the jvm/lib/ext directory in your Notes or Domino installation. Restart the http task if you are testing with Domino.</p>
<ul>
<li><a id="p95" href="http://johankanngard.net/wp-content/uploads/2006/02/XMLEchoer.java">XMLEchoer.java</a></li>
</ul>
<p>[tags]Java, XML, SAX[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String to InputStream</title>
		<link>http://johankanngard.net/2006/02/09/string-to-inputstream/</link>
		<comments>http://johankanngard.net/2006/02/09/string-to-inputstream/#comments</comments>
		<pubDate>Thu, 09 Feb 2006 16:15:44 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/02/09/string-to-inputstream/</guid>
		<description><![CDATA[Arguments in many methods in the Java APIs are of the type InputStream. This is how to get an InputStream from a String, where argument to getBytes, UTF-8, is the encoding to use: InputStream is = new ByteArrayInputStream(myString.getBytes(\"UTF-8\")); [tags]Java[/tags]]]></description>
			<content:encoded><![CDATA[<p>Arguments in many methods in the Java APIs are of the type InputStream. This is how to get an InputStream from a String, where argument to getBytes, UTF-8, is the encoding to use:<br />
<code><br />
InputStream is = new ByteArrayInputStream(myString.getBytes(\"UTF-8\"));<br />
</code><br />
[tags]Java[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/02/09/string-to-inputstream/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Java versions in Lotus Domino and Notes</title>
		<link>http://johankanngard.net/2006/02/09/java-versions-in-lotus-domino-and-notes/</link>
		<comments>http://johankanngard.net/2006/02/09/java-versions-in-lotus-domino-and-notes/#comments</comments>
		<pubDate>Thu, 09 Feb 2006 14:31:50 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/02/09/java-versions-in-lotus-domino-and-notes/</guid>
		<description><![CDATA[1.0 to 3.x: N/A 4.5 to 4.6.7a: JRE/JDK 1.1 5.0 to 5.0.13a: JRE/JDK 1.1.8 6.0 to 6.5.6: JRE/JDK 1.3.1 7.0 to 7.0.3: JRE/JDK 1.4.2 8.0 to 8.0.1: JRE/JDK 1.5.0 IBM also has a list of supported JDKs and JREs. Old JDK/SDK/JRE versions can be downloaded at java.sun.com. [tags]Java, Lotus Domino, Lotus Notes[/tags]]]></description>
			<content:encoded><![CDATA[<dl>
<dt>1.0 to 3.x:</dt>
<dd>N/A</dd>
<dt>4.5 to 4.6.7a:</dt>
<dd>JRE/JDK 1.1</dd>
<dt>5.0 to 5.0.13a:</dt>
<dd>JRE/JDK 1.1.8</dd>
<dt>6.0 to 6.5.6:</dt>
<dd>JRE/JDK 1.3.1</dd>
<dt>7.0 to 7.0.3:</dt>
<dd>JRE/JDK 1.4.2</dd>
<dt>8.0 to 8.0.1:</dt>
<dd>JRE/JDK 1.5.0</dd>
</dl>
<p><a href="http://www.ibm.com">IBM</a> also has a <a href="http://www-1.ibm.com/support/docview.wss?uid=swg21188789">list of supported JDKs and JREs</a>.</p>
<p>Old JDK/SDK/JRE versions can be downloaded at <a href="http://java.sun.com/products/archive/index.html">java.sun.com</a>.<br />
[tags]Java, Lotus Domino, Lotus Notes[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/02/09/java-versions-in-lotus-domino-and-notes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>StringUtils class in Java</title>
		<link>http://johankanngard.net/2006/01/24/stringutils-class-in-java/</link>
		<comments>http://johankanngard.net/2006/01/24/stringutils-class-in-java/#comments</comments>
		<pubDate>Tue, 24 Jan 2006 11:22:23 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://johankanngard.net/?p=58</guid>
		<description><![CDATA[Goodies like explode, leftback, rightback, switchcase, implode, middle, trim, unique etc. can be found in this utility class. The Commons Lang project at Apache Jakarta also has some really great stuff. Chad Schelfhout gave me a correction for the implode(Object[], String):String method and the new method word(String, String, int):String. StringUtils.java CollectionUtils.java NumberUtils.java]]></description>
			<content:encoded><![CDATA[<p>Goodies like explode, leftback, rightback, switchcase, implode, middle, trim, unique etc. can be found in this utility class.</p>
<p>The <a href="http://jakarta.apache.org/commons/lang/">Commons Lang</a> project at <a href="http://jakarta.apache.org">Apache Jakarta</a> also has some really great stuff.</p>
<p><ins datetime="2006-01-24T10:16:07+00:00"><a href="http://www.chadsmiley.com">Chad Schelfhout</a> gave me a correction for the implode(Object[], String):String method and the new method word(String, String, int):String.</ins></p>
<ul class="downloads">
<li><a href='/wp-content/uploads/2006/01/stringutils.java' title=''>StringUtils.java</a></li>
<li><a href='/wp-content/uploads/2007/12/collectionutils.java' title=''>CollectionUtils.java</a></li>
<li><a href='/wp-content/uploads/2007/12/numberutils.java' title=''>NumberUtils.java</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/01/24/stringutils-class-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Domino agents with Netbeans</title>
		<link>http://johankanngard.net/2002/02/03/creating-domino-agents-with-netbeans/</link>
		<comments>http://johankanngard.net/2002/02/03/creating-domino-agents-with-netbeans/#comments</comments>
		<pubDate>Sun, 03 Feb 2002 10:07:07 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://johankanngard.net/wordpress/?p=6</guid>
		<description><![CDATA[Introduction Netbeans is an open source IDE, that is created and executed in a Java environment. It is a flexible and powerful IDE, and if you are tired of the lack of debugging capabilities for Java in the Lotus Domino Designer client, you may want to look at Netbeans. In this short tutorial, I will [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>
<a href="http://www.netbeans.org">Netbeans</a> is an open source IDE, that is created and executed in a Java environment. It is a flexible and powerful IDE, and if you are tired of the lack of debugging capabilities for Java in the Lotus Domino Designer client, you may want to look at Netbeans.<br />
In this short tutorial, I will try to explain how you can set up your environment, to allow you to create, debug and run your agents from Netbeans.
</p>
<h2>Before we start</h2>
<p>
To follow the tutorial, you will have to download the latest version of <a href="http://www.netbeans.org/downloads-rel.html">Netbeans</a>, that was version 3.3 when this article was written. Please refer to the Netbeans documentation on how to install it.<br />
I assume that you have installed Lotus Domino Designer R5 and Lotus Notes R5. If not, please buy it, or download an evaluation copy from <a href="http://www.lotus.com/home.nsf/welcome/r5trial">notes.net</a>.</p>
<p>You also need the <a href="http://java.sun.com/products/jdk/1.1/download-jdk-windows.html">Java Development Kit 1.1.8</a> to compile Java files in the format that Domino / Notes uses internally, AND the <a href="http://java.sun.com/j2se/1.3/">Java Development Kit 1.3.x</a> to be able to start Netbeans. In Lotus Domino Rnext, the Java Virtual Machine will be upgraded to 1.3x.<br />
There might be differences in platform specific things, like environment variables. This tutorial is aimed towards the MS Windows 2000 platform.
</p>
<p><h2>Configuring Agent Runner</h2>
<p>The main subject when designing agents outside the Lotus Domino Designer, is the AgentRunner. The AgentRunner is a part of the Lotus Domino Java package, and allows external Java programs to communicate with Domino as if it were an agent. There is an AgentRunner database in the Notes data directory. This database is used to keep track of the AgentContexts we will create. LetÂ´s head straight for the code!
</p>
<ul>
<li>Make sure you have a local AgentRunner.nsf database. If it does not exist, create it!</li>
<li>Create a new local database with the filename AgentRunnerTests.nsf.</li>
<li>Create a &#8220;dummy agent&#8221; (which should be a &#8220;Run once&#8221;-agent) in this test database, with the following code:</li>
</ul>
<p><code id="dummyagent">import lotus.domino.*;</p>
<p>public class AgentRunnerTest extends DebugAgentBase {<br />
   public void NotesMain() {<br />
   }<br />
}<br />
</code><br />
<a href="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=3&#038;inline=false&#038;name=AgentRunnerTest.java">AgentRunnerTest.java</a></p>
<ul>
<li>Name the agent &#8220;AgentRunner Test&#8221;.</li>
<li>Save and run it.</li>
<li>Look at the Java Debug console in the File\Tools menu. Note that it says &#8220;AgentContext dumped to file AgentRunner.nsf for agent:	AgentRunner Test AgentRunnerTests.nsf Local&#8221;</li>
<li>Open the AgentRunner.nsf database.</li>
<li>Look in the view &#8220;AgentContext&#8221;, and you will see a document that has been created for you! Open it in edit mode. You will see something like this:<br />  <a href="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=1&#038;name=AgentContextDocument.gif" alt="Small picture of AgentContext document"><img src="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=2&#038;name=AgentContextDocumentThumb.gif" border="0" title="Click on the picture to get it in full size" width="140" height="103"/></a> </li>
<li>Make sure that &#8220;Agents runs on&#8221; is &#8220;Run once&#8221; for now. In the future, set this field to a value matching the real agent.</li>
<li>Save your changes</li>
</ul>
<p><h2>Configuring Netbeans</h2>
<p>To let Netbeans know about the Java-classes that we are about to use, we must mount a JAR file as a Netbeans filesystem.</p>
<ul>
<li>In the FileSystem browser, right click on &#8220;FileSystem&#8221;, and select &#8220;Mount&#8221;, &#8220;Archive (JAR, zip)&#8221;.</li>
<li>Browse to your Lotus Notes program directory, usually c:\Lotus\Notes\, and select the file &#8220;Notes.jar&#8221; and click OK.</li>
<li>Netbeans adds the JAR file to the FileSystem browser, and also adds it to the internal CLASSPATH.</li>
</ul>
<p><a href="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=8&#038;name=NotesJar01.gif"><img src="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=9&#038;name=NotesJarThumb01.gif" border="0"/></a></p>
<p><h2>Configuring JAVA_HOME environment variable</h2>
<p>We also have to set up Netbeans to use the external JDK when compiling. This is because you can not run Lotus Domino agents that has been compiled with a JDK that is newer than version 1.1.8, and Netbeans uses JDK 1.2 or higher for internal compiling. There are two ways to set up Netbeans to use an external compiler. The first is to set the environment variable JAVA_HOME to the JDK 1.1.8 directory (i.e. c:\jdk1.1.8) and specify which class that should be compiled with the external compiler. The second is to configure Netbeans to use a specific javac program when compiling the Java class. The first is the simplest, so I will explain that here. If you know how to set up an environment variable, please skip this section.<br />
<a href="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=5&#038;name=EnvironmentVariable01.gif"><img src="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=7&#038;name=EnvironmentVariableThumb01.gif" border="0"/></a></p>
<ul>
<li>Open the &#8220;System&#8221; item in the &#8220;Control Panel&#8221;.</li>
<li>Go to the &#8220;Advanced&#8221; tab.</li>
<li>Click &#8220;Environment Variables&#8230;&#8221;</li>
<li>In the &#8220;System variables&#8221; section, find the &#8220;JAVA_HOME&#8221; variable. If it does not exist, click &#8220;New&#8230;&#8221;.</li>
<li>Make sure the &#8220;JAVA_HOME&#8221; variable value is set to the path where your JDK 1.1.8 is installed, i.e. c:\jdk1.1.8 (note that there should not be any backward slash at the end).</li>
<li>Click &#8220;OK&#8221; in all dialog boxes.</li>
<li>A reboot might be necessary in some circumstances&#8230;</li>
</ul>
<p>One thing remains, and that is to tell Netbeans what source files to compile with the external compiler. I will come to this in a moment&#8230;</p>
<h2>Our first agent</h2>
<p>
When all is configured, let us create an agent OUTSIDE of the Lotus Domino Designer!</p>
<ul>
<li>Create a new Java main class in Netbeans using the wizard, but press finish right after naming the class to &#8220;DominoAgentTest&#8221;</li>
<li>Import the lotus.domino package and make the agent extend DebugAgentBase</li>
<li>To run an agent from outside of Domino, we must make a call to the static main method in lotus.domino.AgentRunner, something like this:</li>
</ul>
<p><code><br />
public static void main(String args[]) {<br />
   try {<br />
      AgentRunner.main(new String[] {<br />
         "AgentRunner Test",      // Agent name<br />
         "AgentRunnerTests.nsf",  // Database<br />
         "local"});               // Server<br />
   } catch(Exception e) {<br />
      e.printStackTrace();<br />
   }<br />
}<br />
</code></p>
<ul>
<li>Write the NotesMain method as you would in a &#8220;normal&#8221;, agent that you create in the Lotus Domino Designer, for example:</li>
</ul>
<p><code><br />
public void NotesMain() {<br />
   try {<br />
      Session session = getSession();<br />
      AgentContext agentContext = session.getAgentContext();<br />
      Database currentDb = agentContext.getCurrentDatabase();<br />
      System.out.println("Current database: " +<br />
            currentDb.getTitle());<br />
   } catch(Exception e) {<br />
      e.printStackTrace();<br />
   }<br />
}<br />
</code><br />
Full source of the first agent, with some extra code: <a href="http://johankanngard.net/wordpress/wp-content/plugins/dbfile/dbfile.php?action=get&#038;id=4&#038;inline=false&#038;name=DominoAgentTest.java">DominoAgentTest.java</a></p>
<ul>
<li>Save the file.</li>
<li>Show the property box of your class, by right clicking on the file in the FileSystem, and selecting &#8220;Properties&#8221;.</li>
<li>Go to the &#8220;Execution&#8221; tab</li>
<li>At the &#8220;Compiler&#8221; option, select &#8220;External Compilation&#8221;. By default, this option uses the JAVA_HOME environment variable explained above.</li>
<li>Compile the file by choosing &#8220;Compile&#8221; in the &#8220;Build&#8221; menu.</li>
<li>If the compilation went alright, you can now try to run it! Choose &#8220;Execute&#8221; in the &#8220;Build&#8221; menu.</li>
<li>The &#8220;Output window&#8221; should now show some printed text from your agent, that has retrieved information from the Notes environment!</li>
</ul>
<h3>Useful links</h3>
<ul>
<li><a href="http://www.codestore.net/A55692/store.nsf/unid/EPSD-59LLJG?OpenDocument">&#8220;Getting yourself ready to create servlets&#8221;</a>, an article at codestore.net, explaining how to create servlets for Domino in Netbeans.</li>
<li><a href="http://www.lotus.com/developers/devbase.nsf/homedata/homejava" target="_blank">Lotus Domino Toolkit for Java/CORBA</a>, a must if you want to get all information about Java programming in Lotus Domino.</li>
<li><a href="http://jakarta.apache.org" target="_blank">Apache Jakarta</a>, an open source community for Java developers.</li>
<li><a href="http://www.lotus.com/developers" target="_blank">Lotus Developers Network</a>, an informational site of developing in Lotus products.</li>
<li><a href="http://www.lotus.com/ldd" target="_blank">Lotus Developer Domain</a>, from the creators of Notes / Domino. Many useful sources, like discussions, documentation, tutorials, articles etc.</li>
<li><a href="http://developer.java.sun.com" target="_blank">Sun Java Developer Connection</a>, all documentation, discussions, tutorials etc. of the Java language.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2002/02/03/creating-domino-agents-with-netbeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
