Few days back,I've tried domiclipse plug-in with Eclipse to test if I can continue my development in Eclipse.I was really impressed with the way my Eclipse started talking to my local( and server ) databases.However, I've found difficulties in accessing Domino objects within Eclipse environment.Also,When I try to sync my work with Notes database , It just creates java class files in my local but doesn't update notes database directly ( I assume need to use "Imported Java" agent to manually upload in domino agent ).
Today I was reading about NotesFactory() class in Domino and found using this class Domino objects can be read/write from Java IDE.Next, I found "Running a Java Program" topic in the help file, which clearly says there are two jar files Notes.jar and NCSO.jar which can be configured in any IDE to access domino objects.I got excited and spent couple of hours to configure Eclipse to access Domino Objects. Finally I've done, Here are those easy steps to accomplish;
1)At very first step, Your machine should have Eclipse setup. You can get it at Eclipse Website
2)Run-time requirements
A computer running a Java application that makes local Domino calls must contain Domino Server, Domino Designer, or Notes Client, and must include Notes.jar in the classpath.
A computer running a Java application that makes remote Domino calls need not contain Domino or Notes, but must contain one of the NCSO archives and must include it in the classpath.
A computer running a Domino agent that makes Domino calls must include Notes.jar in the classpath.
A computer running an applet that makes Domino calls needs no Domino software or classpath assignments. The applet must be loaded from a computer containing a Domino server.
For this example I assume you've Client and Server running on the same machine.
3) Find Notes.jar(for me,C:\lotus\Notes\jvm\lib\ext) and NCSO.jar(for me,C:\Program Files\IBM\Lotus\Domino\data\domino\java) file paths and add in your ClassPath (How to set ClassPath for Java)
4) Start Eclipse, go to File->New->Java Project
4) Right click on newly created project,Choose Properties->Java Build Path and add external Jars.
5) Create new class, Right click on project->New->Class
6) Here is the sample code which I've tried,
import lotus.domino.*; public class AccessDomino { public static void main(String[] args) { try { Session session = NotesFactory.createSession("localhost", "Rishi Sahi/Development", "Development"); Database db = session.getDatabase(null, "ConnectmetoDomino.nsf"); System.out.println(session.getUserName()); System.out.println(db.getSize()); } catch(Exception e) { e.printStackTrace(); } } ; } |
* At very first line I'm importing domino package which contains all the necessary class/methods to start my work.
* I'm using NotesFactory class to create domino session with ServerName,UserName and Password parameters.
* Once session is created use any Domino-Java class to start your work.
One of the main advantage you can attain to use type ahead feature which is still missing in Domino.
7) Before running your program you must ensure that the server notes.ini file contains the following line:
ServerTasks=
If missing then open Notes.ini file and add diiop in your server tasks list and restart domino server. Once done, run your code and check the output,
You can ease your Domino-Java development using domiclipse and above tips.
To setup domiclipse, I would suggest to visit : Coding Thoughts by Carlos
June 26, 2009 at 1:41 AM
I wouldn't put java classes in the OS classpath no more.
I think just adding them to the eclipse project. To try it out, you may follow the steps explained here:
http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)
Advantages:
a) If you share you project with others via a common code repository like subversion or zip the project, there are no dependencies on the settings of the classpath on a different computer.
b) no fun to hassle with those low level OS Variables like Classpath.
c) You will use more and more jars not part of the JDK. If you want for example access DB2, you need their JDBC driver jars, too. You don't want all this stuff in the global classpath in the box. Next day you may try spring-framework. There you need like 22 jars or so.
d) Versioning is much simpler. In one project you may need Notes.jar from Domino 6. And next day Notes.jar for Domino8. You don't want to switch your global classpath each time you work with a different version of Notes.
e) In eclipse you can add the javadoc for imported library in the way described. You get javadoc in popup window.
June 26, 2009 at 1:46 AM
Hi Axel,
Thanks for sharing this cool tip,I was still in the world where JARs are set in the ClassPath :(.
June 26, 2009 at 2:00 AM
Another one.
Its a better idea to not uses jdk6, but the one notes uses.
If the project in Eclipse uses jdk 6 and Domino an earlier version, you may be tempted to use classes/methods/syntax, which hasn't been suported in the java version domino uses.
Open Eclipse.
Go Menu -> Window / Preferences
In the box select java and there installed jres.
Press "add" button on the right.
A dialog opens.
Fill the name field and select the home directory of the notes (or domino) vm.
My notes8 client is in C:/Notes8. So I select JRE Home directory C:/Notes8/jvm.
Press ok. The Notes8 jre is added to the list of installed jres.
press ok.
If you now do like "File New Java Project". You can select the JVM specific to your project in the first dialog (use a project specific jre).
June 28, 2009 at 6:12 PM
@Axel, I did unknowingly while configuring Domiclipse :).
Thanks for letting me know the purpose.
October 27, 2010 at 8:46 PM
Someone knows exactly what should I do to be able to have an executable jar file capable to be executed by any JRE and not only that one provided by Notes. I was able to have my code running on Eclipse but using Notes JRE. Every time I tried to change to another one I got on problems.
July 4, 2012 at 9:51 AM
I realize this is an old thread, but the main reason you can't just use any JRE is because the Notes jar files are wrappers around native calls (probably using JNI). I found that I was unable to use a 64-bit JVM to run them. "Write once, run anywhere" is an "almost, but not quite" thing.