<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Calling Java classes from LotusScript</title>
	<atom:link href="http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/</link>
	<description>Lotus Notes tips &#38; tricks you always hoped you will not need</description>
	<lastBuildDate>Wed, 14 Dec 2011 20:40:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Vladimir Kocjancic</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-1142</link>
		<dc:creator>Vladimir Kocjancic</dc:creator>
		<pubDate>Tue, 13 Sep 2011 07:57:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-1142</guid>
		<description>In my case, you would need to modify my CUserLogin LotusScript class and make &lt;b&gt;js&lt;/b&gt; variable a class member and not a local variable. After that, you just modify Run() method of the class with error handling and in that error handling, you call js.getLastJavaError() .

Remodeled CUserLogin class would now look like:

&lt;pre&gt;Uselsx &quot;*javacon&quot;
Use &quot;jclass:UserLogin&quot;

Class CUserLogin
	loginObj As JavaObject
	js As JAVASESSION

	Sub New (strUsername As String, strPassword As String)
		Dim loginClass As JAVACLASS

		Set js = New JAVASESSION
		Set loginClass = js.GetClass (&quot;CUserLogin&quot;)
		Set loginObj = loginClass.CreateObject ()

		Call loginObj.Initialize (strUsername, strPassword)
	End Sub

	Function run() As Boolean
		Dim myError as JavaError
		
		On Error GoTo ErrorHandling
		run = loginObj.run()
		Exit Function
	
	ErrorHandling:
		myError = js.getLastJavaError()
		Messagebox myError.ErrorMsg
		Messagebox myError.StackTrace
		Call js.ClearJavaError()
	End Function
End Class&lt;/pre&gt;

This &lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/LSAZ_USING_LS2J_MIDTOPIC_227115017629463475.html&quot; rel=&quot;nofollow&quot;&gt;link&lt;/a&gt; describes how to handle LS2J exceptions in detail and much of other LS2J tricks :)</description>
		<content:encoded><![CDATA[<p>In my case, you would need to modify my CUserLogin LotusScript class and make <b>js</b> variable a class member and not a local variable. After that, you just modify Run() method of the class with error handling and in that error handling, you call js.getLastJavaError() .</p>
<p>Remodeled CUserLogin class would now look like:</p>
<pre>Uselsx "*javacon"
Use "jclass:UserLogin"

Class CUserLogin
	loginObj As JavaObject
	js As JAVASESSION

	Sub New (strUsername As String, strPassword As String)
		Dim loginClass As JAVACLASS

		Set js = New JAVASESSION
		Set loginClass = js.GetClass ("CUserLogin")
		Set loginObj = loginClass.CreateObject ()

		Call loginObj.Initialize (strUsername, strPassword)
	End Sub

	Function run() As Boolean
		Dim myError as JavaError

		On Error GoTo ErrorHandling
		run = loginObj.run()
		Exit Function

	ErrorHandling:
		myError = js.getLastJavaError()
		Messagebox myError.ErrorMsg
		Messagebox myError.StackTrace
		Call js.ClearJavaError()
	End Function
End Class</pre>
<p>This <a href="http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=/com.ibm.designer.domino.main.doc/LSAZ_USING_LS2J_MIDTOPIC_227115017629463475.html" rel="nofollow">link</a> describes how to handle LS2J exceptions in detail and much of other LS2J tricks <img src='http://www.lotushints.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kenneth</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-1137</link>
		<dc:creator>Kenneth</dc:creator>
		<pubDate>Mon, 12 Sep 2011 13:03:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-1137</guid>
		<description>Excellent tip, but exactly how is errorhandling performed between Java and LotusScript? If I throw an error in a Javaclass method (lets say the run() function in Your example) - what are populated up to the LotusScript class? When I tried I only succeeded in giving an errormessage to the exception, not any errornumber...
If I throw an Exception in the run(), then the only thing that is populated up the chain is the message that I provide. The errornumber will always be #318. And whats worse is that the error message will be prefixed with &quot;- LS2J Error threw java.lang.Exception&quot;.
Do You have any solution for giving LotusScript the correct errornumber and the correct errormessage?</description>
		<content:encoded><![CDATA[<p>Excellent tip, but exactly how is errorhandling performed between Java and LotusScript? If I throw an error in a Javaclass method (lets say the run() function in Your example) &#8211; what are populated up to the LotusScript class? When I tried I only succeeded in giving an errormessage to the exception, not any errornumber&#8230;<br />
If I throw an Exception in the run(), then the only thing that is populated up the chain is the message that I provide. The errornumber will always be #318. And whats worse is that the error message will be prefixed with &#8220;- LS2J Error threw java.lang.Exception&#8221;.<br />
Do You have any solution for giving LotusScript the correct errornumber and the correct errormessage?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dilip Patel</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-1110</link>
		<dc:creator>Dilip Patel</dc:creator>
		<pubDate>Wed, 27 Jul 2011 23:10:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-1110</guid>
		<description>Thanks for the tip
very useful for a first time java/lotusScript combination user</description>
		<content:encoded><![CDATA[<p>Thanks for the tip<br />
very useful for a first time java/lotusScript combination user</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vladimir Kocjancic</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-638</link>
		<dc:creator>Vladimir Kocjancic</dc:creator>
		<pubDate>Fri, 24 Apr 2009 12:49:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-638</guid>
		<description>I doubt you can do that. What you can do, is create your own Java Class that encapsulates mentioned singleton class. Then you can write a LotusScript class that loads that Java class. I know this is a tad awkward, but I don&#039;t really see any other possibility.</description>
		<content:encoded><![CDATA[<p>I doubt you can do that. What you can do, is create your own Java Class that encapsulates mentioned singleton class. Then you can write a LotusScript class that loads that Java class. I know this is a tad awkward, but I don&#8217;t really see any other possibility.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Steele</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-635</link>
		<dc:creator>Brian Steele</dc:creator>
		<pubDate>Thu, 23 Apr 2009 23:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-635</guid>
		<description>Actually, I meant a Java singleton class with private constructors.  When I call the CreateObject method from Lotusscript, it chokes because it can&#039;t find a constructor in the Java class.</description>
		<content:encoded><![CDATA[<p>Actually, I meant a Java singleton class with private constructors.  When I call the CreateObject method from Lotusscript, it chokes because it can&#8217;t find a constructor in the Java class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vladimir Kocjancic</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-634</link>
		<dc:creator>Vladimir Kocjancic</dc:creator>
		<pubDate>Thu, 23 Apr 2009 17:24:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-634</guid>
		<description>As a matter of fact, I sort of do. In &lt;a href=&quot;http://www.lotushints.com/2008/11/design-patterns-part-3-singleton-pattern/&quot; rel=&quot;nofollow&quot;&gt;Part 3 of Design patterns series&lt;/a&gt;, I did exactly that. Mind you, you cannot have a private constructor in LotusScript, so what you have to do is create a private class with public constructor, which disables any code but the one in the library to create new class. Then, you don&#039;t have static methods or variables in LotusScript, so what you need to do is a public function that will return instance of singleton class.</description>
		<content:encoded><![CDATA[<p>As a matter of fact, I sort of do. In <a href="http://www.lotushints.com/2008/11/design-patterns-part-3-singleton-pattern/" rel="nofollow">Part 3 of Design patterns series</a>, I did exactly that. Mind you, you cannot have a private constructor in LotusScript, so what you have to do is create a private class with public constructor, which disables any code but the one in the library to create new class. Then, you don&#8217;t have static methods or variables in LotusScript, so what you need to do is a public function that will return instance of singleton class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Steele</title>
		<link>http://www.lotushints.com/2009/02/calling-java-classes-from-lotusscript/comment-page-1/#comment-631</link>
		<dc:creator>Brian Steele</dc:creator>
		<pubDate>Thu, 23 Apr 2009 04:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.lotushints.com/?p=210#comment-631</guid>
		<description>I don&#039;t suppose you have any suggestions for how to instantiate a Singleton class that has no public Constructors?</description>
		<content:encoded><![CDATA[<p>I don&#8217;t suppose you have any suggestions for how to instantiate a Singleton class that has no public Constructors?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

