Message649

Author nobody
Recipients
Date 2004-01-23.20:55:11
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Logged In: NO 

Here's a workaround.  Import JythonClassPathMagic before
accessing the
java code in the jar file manifest Class-Path.

Jeff Emanuel
jemanuel@lgc.com

JythonClassPathMagic.py:
import java,sys

# This adds the class path elements specified in jar file
manifests to
# the jython package manager so the java packages and
classes listed
# in the manifests can be imported in jython.

def handleJarClassPath(jcp,parent):
  for p in jcp.split():
    f = java.io.File(parent,p)
    if p[-1]=='/':
      sys.packageManager.addDirectory(f)
    else:
      sys.packageManager.addJar(f.canonicalPath,1)

classpath=java.lang.System.getProperty('java.class.path')
for element in
classpath.split(java.lang.System.getProperty('path.separator')):
  try:
    jar = java.util.jar.JarFile(element)
    if jar:
      if jar.manifest:
        jarAttrs = jar.manifest.mainAttributes
        jarClassPath =
jarAttrs[java.util.jar.Attributes.Name.CLASS_PATH]
        if jarClassPath:
          f=java.io.File(element)
          handleJarClassPath(jarClassPath,f.parentFile)

  except java.io.IOException:
    pass
History
Date User Action Args
2008-02-20 17:17:05adminlinkissue547727 messages
2008-02-20 17:17:05admincreate