The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by norbertanthony]

I tried the standalone application example in Chapter 5 and got a number of
errors. I also noticed that the code given for this example in the source code
database that was downloaded from the site is different from the one in the
book. Any ideas? Has anyone tried this?
import-bot (20211) [Avatar] Offline
#2
Re: Errors in Code Example 5_2
[Originally posted by aspatton]

Yes, I apologize for the error. I will post it to the errata and correct the
download code. Send me an email at tpatton@tisny.com and I'll send you a
correct Java source file.

Here is the correct code. The errors are in line labelled '1' and '5'. The
wrong class name is used in 1, it should use the Example_5_2 class name. Line
5 should use your Domino server address along with your username and password.
The code below uses my Domino Server running locally.

-------------------------------------------------------------------

import lotus.domino.*;

public class Example_5_2 implements Runnable {
public static void main(java.lang.String[] args) {
Example_5_2 t = new Example_5_2();
Thread nt = new Thread((Runnable)t);
nt.start();
}
public void run() {
try {
Session s =
NotesFactory.createSession("127.0.0.1:81","apatton","password");
String p = s.getPlatform();
String cu = s.getCommonUserName();
String nv = s.getNotesVersion();
String sn = s.getServerName();
String un = s.getUserName();
System.out.println("Current Platform: " + p);
System.out.print("Current username: ");
System.out.println(s.getCommonUserName());
System.out.println("Current Common Username: " + cu);
System.out.println("Current Notes Version: " + nv);
if (sn.trim() == "") {
System.out.println("We are working locally.");
} else {
System.out.println("We are working on the server: " + sn);
}
if (s.isOnServer()) {
System.out.println("We are working on the server.");
} else {
System.out.println("We are working locally.");
}
s.recycle();
} catch (NotesException n) {
System.out.println("ID: " + n.id + " -- Name: " + n.text);
} catch (Exception e) {
e.printStackTrace(); }}}

-------------------------------------------------------------------

Once again, I apologize.

Tony.
import-bot (20211) [Avatar] Offline
#3
Re: Errors in Code Example 5_2
[Originally posted by ssn651]

Actually I have a question about the expected results of the sample code. In
the book on pg 41 the output shows that the session property for the server
name indicated a local situation even when supposedly the session was based on
a specified server, if I undedrstood you code correctly. I am confused, if you
run an agent from a client - will you always get an indication of working
locally even if you are "working on" a database on a server? If that is the
case then would you get the server name if the agent was run on a scheduled
basis and then which server name would you get - the server name for the one
the agent is executed on or the one for the database the agent is calling. Or
is the most appropriate method to get the server name of the database being
worked to use the database servername property?

Could you also tell me what the word void is representing/trying to tell me
when it is used in the code as part of declaring a method. Does it stand for
variable object id or is it an actual reference to the word void, if so why
void?