Re: [Jpype-users] Multiple Start and Shutdown
Status: Beta
Brought to you by:
devilwolf
From: <je...@le...> - 2011-04-13 20:20:45
|
Thanks Steve for the quick response. I was hesitant to try building a custom classloader because I wasn't sure how that would play with JPype and I don't know enough java to debug it. I'm going to try to avoid the issue by just using a global setting for the class path that can be all encompassing. If (when) that doesn't suffice I'll try writing my class loader. If I find anything interesting I'll try to post it. Jeremy Quoting Steve Ménard <men...@gm...>: > Interesting use case ... > > It "should" work, but JVM loading/unloading is an iffy subject at best. All > those classes that were already loaded using the first JVM instance will > stay tehre (at least their python counterpart) but not be useable ... > > Add to that the enormous overhead of starting.stopping the JVM, and I > stringly suggest you look into other solutions. > > If both your ptyhon modulesa re loaded before the JVM starts, they could add > their dependencies to a registry of some sort, and then when teh JVM starts > those dependencies cann be pulled into a single JVM. > > Failing that, you could look into using a custom classloader. They are nto > very ahrd to make, and some of them will allow you to change the classpath > at runtime. They are nto very ahrd to make (you could even find a ready-made > one). > http://kalanir.blogspot.com/2010/01/how-to-write-custom-class-loader-to.htmlgives > you one simple example. > > Steve Menard > > ------------------------------ > Programming today is a race between software engineers striving to build > bigger and better idiot-proof programs, and the Universe trying to produce > bigger and better idiots. So far, the Universe is winning. > Rick Cook, The Wizardry Compiled > ------ > There are two major products that come out of Berkeley: LSD and UNIX. We > don't believe this to be a coincidence. > -- Jeremy S. Anderson > > > On Wed, Apr 13, 2011 at 4:00 PM, <je...@le...> wrote: > >> Hi, >> >> Suppose I try to do the following >> startJvm->Shutdownjvm ->startjvm >> >> jpype throws an exception "unable to start jvm" when I try to restart the >> jvm. >> >> The reason I'm trying to do this is because I want to make sure the >> classpath is set a certain way and my understanding is that you can't >> set the classpath at runtime; so I need to start the jvm and specify >> the classpath. >> >> Here's why: >> I have two independent functions "funcA" and funcB both of which use >> jpype to execute java code. funcA needs libfunca.jar and funcb >> needs libfuncb.jar. I'd like funcA and funcB to be able to start the >> jvm and execute the approriate java code without forcing funcA/funcB >> to know about what jars the other one needs to be on the classpath. so >> funca should only know that libfunca.jar needs to be on the classpath; >> and should start the jvm with only libfunca.jar on the classpath. >> >> Any suggestions how to solve this? >> >> Thanks. >> >> >> Jeremy >> >> >> >> ------------------------------------------------------------------------------ >> Benefiting from Server Virtualization: Beyond Initial Workload >> Consolidation -- Increasing the use of server virtualization is a top >> priority.Virtualization can reduce costs, simplify management, and improve >> application availability and disaster protection. Learn more about boosting >> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev >> _______________________________________________ >> Jpype-users mailing list >> Jpy...@li... >> https://lists.sourceforge.net/lists/listinfo/jpype-users >> > |