> 
> On Jul 24, 2008, at 1:09, Bill Janssen <[EMAIL PROTECTED]> 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.

I think it's time to add this simple trick, and command line flag.

This works fine for me on OS X with Java 5 (system Python, system
Java, latest JCC):

python -m jcc --shared --include goodstuff.jar --python goodstuff \
          --version 1.0.0 --package java.lang --package java.util \
          java.io.File --debug --build

But this gives me the error:

python -m jcc --shared --include goodstuff.jar --python goodstuff \
          --version 1.0.0 --package java.lang --package java.util \
          java.awt.image.BufferedImage --debug --build

I need BufferedImage for my application, so...

In the interest of completeness, here's what's in goodstuff.jar:

  import java.awt.image.*;
  import javax.imageio.*;

  class GoodStuff {

    static public void main (String[] argv) {

        try {
            BufferedImage b = ImageIO.read(new java.io.File(argv[0]));
            System.out.println("Size of image is " + 
                b.getWidth() + "x" + b.getHeight());
        } catch (Exception x) {
            x.printStackTrace(System.err);
        }
    }
  }

Bill


_______________________________________________
pylucene-dev mailing list
pylucene-dev@osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to