Include jar library in nsf file

Hi there,

I just wondering how I can include a jar-library into my *.nsf database and use its classes.

I do the following in Designer:

  • Shared Resources - Files - New File Resource - there I can add the jar library - so I do

  • JTwain.jar exists now in my nsf database

When I try to call a method from my agent, e.g. with the import statement

“import com.asprise.util.jtwain.Source;” I get the simple Error: package com.asprise.util.jtwain

does not exist

Also there is no chance with “Edit Project” in the Designer Agent window: when I browse to “Shared Java Libraries”

nothing of the jar library will be displayed.

So how is it possible. I know that I can put the jar library into my notes.ini pathes, but this is not the task.

The nsf-File should be an “All included package” where the user can download it onto his server and just use it

(without copying files into local directories)

Did I forget to set rights. Appreciate every help.

Thanks in advance

Holm

Subject: Include jar library in nsf file

Put jar file anywhere in file system of Domino server. Add location of these jar files to notes.ini → JavaUserClasses variable. If multiple JAR files are there add them separated by comma.

Regards

Litty Joseph

Subject: RE: Include jar library in nsf file

This is not an anwser to the OP’s question. The OP wants to know how to place the Jar in an NSF. I think what the OP is trying to attempt is to place security on the JAR. Placing the jar in the filesystem would allow anyone that has acccess to the server to run the servlets if placed on the file system.

Holm, I have been wanting to do this myself. I hope you get an answer.

Subject: RE: Include jar library in nsf file

Hi Litty,

thanks for your quick response but as Bruce wrote: this is exactly what I don’t want to do!!!

The problem is the following: I coded something for a customer. I will take the nsf file, copy it with notes and the whole stuff works on the fly without altering the ini file, restarting domino, etc.

There must be a way to put it into the nsf file and use it.

Thanks anyway

Holm

Subject: RE: Include jar library in nsf file

I don’t think that there is any way to use a jar stored as a file resource. You can however import it into a Java ScriptLibrary and make it available to Java agents that way.

Subject: SOLVED: Include jar library in nsf file

Thanks to Harkpabst here is a step by step solution how it works: Remember: I want to add a jar library to an nsf file.I DON’T want to add the jar library to my CLASSPATH neither on my computer nore on my server.

Here is how it works:

  • Important: I have Notes 7.0 so everything should be compiled in Java 1.4, Notes 7.0 can not handle

    JDK > 1.4

  • How to do that?

  • e.g. in Eclipse you can change the compile modus under Window - Preferences - Java - Compiler and

    change the “Compiler compliance level” to 1.4 - recompile all java files

  • next is you create a jar library: e.g. in Eclipse you right click on the project and choose Export - Jar library …

  • save the jar library

  • under windows (via a command shell) or linux (via a shell) go into the directory where you saved the jar library

  • under windows rename the file → ren oldfile.jar newfile.zip

  • same under Unix → mv oldfile.jar newfile.zip

  • unzip the file with your favorite zip program

  • Open the Designer and the corresponding database where you want to store the classes

  • go to Shared Code - Script Libraries

  • Choose New Java Library

  • Choose Edit Project (you see the button at the bottom)

  • on the left site choose “Local File System” and click on the directory button

  • navigate to the folder where you unzipped the jar (zip) file

  • ATTENTION: if your java package is called, e.g. org.java.twain.* you have to navigate to the root of org,

    otherwise notes will not find the package

  • left click on the package name (highlight it … here in my case “org” is highlighted)

  • click on checkbox “Show file types” “All” und push the “Add/Replace File(s)” button

  • all classes should be now in the right window

  • click “OK” and click “Save” - give the library a unique name (in my case: twaindriver)

  • go to the Java-Agent

  • click on “Edit Project”

  • change on the left “Browse - Local File System” to “Browse Shared Java Libraries”

  • you should be now able to see the name of the package name under you saved all class files

  • highlight the package (in my case: twaindriver) und push button: “Add/Replace File(s)”

  • the Library should be now on the right site

  • you should be now able to import the classes: in my case import org.java.twain.*

Have fun

Holm

Subject: RE: SOLVED: Include jar library in nsf file

Well, it SHOULD actually work without unzipping the jar file.

In the “edit project” dialog, just pick the right base directory that holds the jar file and click OK. Do NOT expect the actual files to show up in that dialog (although it looks like a regular file selector).

Next make sure, that in the “show file types” sections, “archives” (and only archives) is checked. You should now see all the jar files in your base directory inside the very same dialog.

Select whatever you need and hit “add or replace files”.

If necessary, reorder your inputs on the right side of the dialog.