Message1545

Author mr_tines
Recipients
Date 2007-04-01.22:36:31
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
Jython 2.2b1, installed in standalone mode i.e. all of /Lib inside the jar, and cachedir being skipped.

This affects more than just .awt in java; plus all of javax.

The following code works with Jython launched from the jar in the standard install:

import java.awt
f = java.awt.Frame()
f.title = "Hello AWT"
f.visible = True

but when run with Jython.jar from the standalone install the code gives

C:\jython2.2b1-standalone>java -jar jython.jar
Jython 2.2b1 on java1.6.0 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import java.awt
Traceback (innermost last):
  File "", line 1, in ?
ImportError: no module named awt
>>> ^Z

WORKROUND

You need to nudge the system to do what caching would have done:-

import sys
sys.packageManager.makeJavaPackage("java.awt", "Window", None)
import java.awt
f = java.awt.Frame()
f.title = "Hello AWT"
f.visible = True

NOT WORKROUND

This does not work: 

try:
  import java.awt
except ImportError:
  import sys
  sys.packageManager.makeJavaPackage("java.awt", "Window", None)
  import java.awt

-- the second import fails as if the makeJavaPackage didn't stick (scoping effect?)


History
Date User Action Args
2008-02-20 17:17:47adminlinkissue1692579 messages
2008-02-20 17:17:47admincreate