Dear Chris,

The present "classPathHack" has nothing to do with the Jython language, its a tweak for the Java classpath itself, which allows to dynamically append a .jar file after the JVM was already initialized. It fixes a few of the classes in Java that might show problems using reflection. This classPathHacker code is well known under Java, I simply rewrote it in a Jython syntax.

If the hack did not work, the issue relates clearly to class loader of the Jython 2.2.1 version. Hope the work-around with the redundant import you found, gives you a chance to live with the problem.  

Regards,
Claude


Claude Falbriard
Certified IT Specialist L2 - Middleware
AMS Hortolāndia / SP - Brazil
phone:    +55 13 9760 0453
cell:         +55 13 8117 3316
e-mail:    claudef@br.ibm.com




From:        Chris Clark <Chris.Clark@actian.com>
To:        claudef@br.ibm.com
Cc:        Jython-users@lists.sourceforge.net
Date:        03/02/2012 16:10
Subject:        Re: [Jython-users] import failures of core java libraries with Jython 2.2.1




Thanks for taking a look Claude, were you able to use your class path
hacker to import the core libraries I was unable to load? If so, can you
show a demo so I can see what you did.

I've a similar class path hacker in jyjdbc which works for the 2.2 and
2.5 series (I posted something a while back to the list as the Jython
book version doesn't work on all versions of 2.5.*) so I'll probably end
up using that if this is a classpath issue.

One interesting discovery is that whilst awt fails to import, there
appears to be a way to make it work (I saw some code in
http://code.google.com/p/jythonconsole/ which inspired the following
kludge):

   C:\jythonconsole_svnhg>java -jar c:\jython2.2.1\jython.jar
   Jython 2.2.1 on java1.6.0_21
   Type "copyright", "credits" or "license" for more information.
    >>> import java.awt
   Traceback (innermost last):
      File "<console>", line 1, in ?
   ImportError: no module named awt
    >>> from java.awt import Color, Font, Point
    >>> import java.awt
    >>>


NOTE the second attempt to import awt works fine :-S

This then appears to allow import of pawt too. Similarly something can
be done for sql too:

    >>> import java.sql
   Traceback (innermost last):
      File "<console>", line 1, in ?
   ImportError: no module named sql
    >>> from java.sql import Types
    >>> import java.sql
    >>>

That also works! I'll probably go with redundant imports as a workaround
unless anyone has ideas/comments.

Thanks

Chris


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users