[pylucene-dev] OS X JCC can't wrap java.awt classes

Andi Vajda vajda at osafoundation.org
Wed Jul 23 16:24:35 PDT 2008


On Jul 24, 2008, at 1:09, Bill Janssen <janssen at parc.com> wrote:

> So, I switched off that Linux machine to my Mac (OS X 10.5, Java 5,
> latest JCC, built shared, system Python 2.5).
>
> Now I'm getting a different problem.  I'm trying to wrap some AWT
> classes (java.awt.BufferedImage, java.awt.Rectangle,
> javax.imageio.ImageIO).  This works fine on 32-bit Linux.  But when I
> try on OS X, I get this:
>
> % python -m jcc --shared --include GoodStuff.jar --python docfinder  
> --version 1.0.0 --package java.lang --package java.util  
> com.parc.GoodStuff java.awt.Rectangle java.awt.image.BufferedImage  
> javax.imageio.ImageIO java.io.File --debug --build
> 2008-07-23 16:02:50.514 Python[76738:60b] Apple AWT Java VM was  
> loaded on first thread -- can't start AWT.
> Traceback (most recent call last):
>  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/runpy.py", line 95, in run_module
>    filename, loader, alter_sys)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/runpy.py", line 52, in _run_module_code
>    mod_name, mod_fname, mod_loader)
>  File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/ 
> python2.5/runpy.py", line 32, in _run_code
>    exec code in run_globals
>  File "/Library/Python/2.5/site-packages/JCC-1.9-py2.5-macosx-10.5- 
> i386.egg/jcc/__init__.py", line 28, in <module>
>    cpp.jcc(sys.argv)
>  File "/Library/Python/2.5/site-packages/JCC-1.9-py2.5-macosx-10.5- 
> i386.egg/jcc/cpp.py", line 358, in jcc
>    cls = findClass(className.replace('.', '/'))
> jcc.cpp.JavaError: java.lang.InternalError: Can't start the AWT  
> because Java was started on the first thread.  Make sure  
> StartOnFirstThread is not specified in your application's Info.plist  
> or on the command line

I've never done this myself or used the java.awt classes. It looks  
like an Apple or Sun bug to me that one can't load an awt class from  
the main thread.
Could you search forums and web to see if there is a simple workaround ?

A simple trick to work this around with JCC would be to spawn a thread  
and have it do the code generation instead of the main thread. It'd be  
easy enough to add as yet another JCC command line flag.

Andi..

>
> %
>
> _______________________________________________
> pylucene-dev mailing list
> pylucene-dev at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/pylucene-dev


More information about the pylucene-dev mailing list