Re: [Objectscript-users] using mountJarFile
Brought to you by:
rob_d_clark
From: Lysander D. <sa...@sb...> - 2005-10-07 18:11:02
|
Thanks for the quick response. Since that doesn't modify the classpath for the classloader, is there an accepted way to set up a new classloader with a classpath defined at runtime. As quick hack, I've compiled the AntClassloader2 and was able to load a class from a runtime-defined classpath in plain java. If that is acceptable within objectscript, how would it be possible to make the JavaPackage object aware of the AntClasloader2 ? Thanks again, Lysander --- Rob Clark <ro...@ti...> wrote: > A couple things... > > first, mounting it just makes it available within > the abstract > filesystem. So you could then, for example, use > pkg.fs.File() to > access files within the jar (ie > "/jar/xstream-SNAPSHOT/foo/bar.os"). > And of course if you have script files within the > jar, they could be > imported or accessed thru pkg. But it does not add > the jar to the > classpath. (Although I think this could be > implemented, and it is an > interesting idea... I'll have to look into it.) > > second, you will probably need to use > pkg.system.declareJavaPackage() > for any java package that is first accessed from the > script > environment, otherwise the JavaPackage object has no > way to know that > the package actually exists, and so it will throw a > > NoSuchMemberException. > > > > On Oct 6, 2005, at 6:10 PM, Lysander David wrote: > > > Hi, > > > > How does one use pkg.system.mountJarFile ? > > > > I am attempting to instantiate an object of > > class com.thoughtworks.xstream.XStream. > > The class exists in this jar: > > > > xstream-SNAPSHOT.jar > > > > When I execute these commands: > > > > import "reflection.os"; > > var file = new pkg.fs.File ( > "xstream-SNAPSHOT.jar" ); > > pkg.system.mountJarFile ( file ); > > var com = new JavaPackage ("com" ); > > var x = new com.thoughtworks.xstream.XStream(); > > > > > > I get this error: > > > > oscript.exceptions.PackagedScriptObjectException: > > NoSuchMemberException: no such member: > JavaPackage: > > thoughtworks > > > > > > What must be done to mount xstream-SNAPSHOT.jar > > and instantiate com.thoughtworks.xstream.XStream ? > > > > Thanks > > > > -- Rob > > ____________________ > CONTACT INFORMATION: > email: ro...@ti... > IM: rob@sandjabber > > > > |