Sidebar

How do I fix "ReferenceError: 'jcifs' is not defined." when trying to use the JCIFS external library?

+1 vote
1.1K views
asked Jul 5, 2013 by ron-s-6919 (4,480 points)
I have correctly included the jcifs.jar using the 'Manage External Libraries' button in System Configuration, however, when I attempt to use one of the classes (jcifs.smb.NtlmAuthenticator) or import the package (jcifs.smb), I receive the following error:

ReferenceError: "jcifs" is not defined

1 Answer

+1 vote
 
Best answer

To use 3rd party libraries that includes classes in packages other than com, org and java, you can preface the package with the text "Packages.".  In other words, to use the NtlmAuthenticator class from the JCIFS library you can use the following:

var myAuth = new Packages.jcifs.smb.NtlmAuthenticator();

Alternatively, you can import the package and use the class as follows:

importPackage(Packages.jcifs.smb);

var myAuth = new NtlmAuthenticator();

For an explanation on the "Packages." keyword, see the following link which states the following:

External packages and classes can also be used as in Rhino. Make sure your .jar or .class file is on you classpath then you may import them into your JavaScript application. These packages are likely not in the java package, so you'll need to prefix the package name with "Packages."

answered Jul 5, 2013 by ron-s-6919 (4,480 points)
selected Jul 5, 2013 by mike-r-7535
commented Jul 17, 2013 by ron-s-6919 (4,480 points)
JDK7 documentation for the importPackage can be found at:
http://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/#jsimport
commented Jul 15, 2019 by rich-c-2789 (16,180 points)
The original jCIFS api (used to access remote SMB shares) referenced in this question is deprecated because it only supports SMB version 1.  However, this example is not about using jCIFS but how to reference external library jars.  Which is still valid.  If you need to access remote SMB network shares, QIE now has support via the NetFile class used in mapping code and via the Network Share source and destination types.
...