Subj : Re: importPackage Search To : "Edwin S. Ramirez" From : Igor Bukanov Date : Wed Jan 22 2003 10:15 pm Edwin S. Ramirez wrote: > Hello, > > I have recently started playing with Rhino. I am using the Rhino > engine within an applet. I have noticed that when importing a package > "importPackage(java.awt)", it makes requests to the server for the > classes. The server reponds with a "file not found", and it seems to > eventually find the class somewhere else. Is there a way to > change/disable this? As there is no easy way in Java to now if x.y.z is a package or class name, Rhino always tries to find a class with the given name, and if it is not present, it will assume a package name. Thus when you pass java.awt to importPackage, java.awt is evaluated and as a part of this evaluation Class.forName("java.awt") will be called which will first search your jar and then Java will append java/awt.class to your applet codebase and query server for it. If you use importPackage several times, then a class will be searched in each package which would also generate requests to the server if the class is not found in the first package. As a workaround I suggest not no use importPackage, but introduce shortcuts like: var S = javas.swing; var A = java.awt; var button = new S.JButton(); var font = new A.Font(); Another possibility is to point your applet codebase to the jar itself: where you may want to use some JavaScript with document.write not to hard code the server address and the absolute jar path. Regards, Igor .