You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Calling Swing/AWT components with JavaCall on OS X #32
i would like to call swing/awt components with JavaCall. But there seems to be some thread issues. Frames do not open.
I think this is not an JavaCall issue but an cocoa/JNI thing but maybe someone knows a workaround for JavaCall on OS X?
FWIW, the Python - Java bridge library jpype also seems to have problems with Swing/AWT on OSX. Something about the threading? I don't understand the reasons fully, as I don't have access to a Mac or do much Java GUI programming. Still, it's reasonable that the issue here has the same underlying cause.
Here are two issues with discussions that might be helpful to you:
In the JPype issue, did they find a solution? I do not have a Mac to test this code on. My suggestion would be to use interprocess communication rather than in-process interop to get around the GUI issues. For example: https://github.com/jbytecode/juliacaller
Another idea would be to use ZeroMQ (ZMQ) to drive the application.
No, the JPype issue has not been fixed. They don't have a Mac to test on, and neither do I.
Interprocess communication would be slower, and not worth it because doing it in-process is most likely possible. There is information in the discussion for those other two issues that might provide hints for what needs to be done to fix this problem with this library.
Activity
aviks commentedon Apr 24, 2016
I've investigated a little bit, and couldn't come up with any answers. It would be good to get this working.
jarnoharno commentedon Sep 13, 2016
I ran into this issue too. It occurs even if I just call things like
ImageIO.getCacheDirectory(): a GUI application opens and Julia hangs.aviks commentedon Sep 13, 2016
Try starting the JVM with "-Djava.awt.headless=true". That will not make graphics work, but might help with the hang.
jarnoharno commentedon Sep 13, 2016
That did it, thanks a lot!
mkitti commentedon May 4, 2020
Is there still a problem on OS X? I do not have a problem on Linux.
hx2A commentedon Feb 17, 2021
FWIW, the Python - Java bridge library jpype also seems to have problems with Swing/AWT on OSX. Something about the threading? I don't understand the reasons fully, as I don't have access to a Mac or do much Java GUI programming. Still, it's reasonable that the issue here has the same underlying cause.
Here are two issues with discussions that might be helpful to you:
jpype-project/jpype#906
jpype-project/jpype#911
And separately, does this library work on Java 11? If not, are there plans to support it in the future?
mkitti commentedon Feb 17, 2021
This library does work on Java 11.
hx2A commentedon Feb 17, 2021
Interesting. The documentation seemed to imply it was only tested on versions 7, 8, and 9.
I'm happy this library exists and will start using it.
mkitti commentedon Feb 17, 2021
Actually, the way I would say it is that the minimum version is now Java 8:
In the JPype issue, did they find a solution? I do not have a Mac to test this code on. My suggestion would be to use interprocess communication rather than in-process interop to get around the GUI issues. For example:
https://github.com/jbytecode/juliacaller
Another idea would be to use ZeroMQ (ZMQ) to drive the application.
hx2A commentedon Feb 17, 2021
No, the JPype issue has not been fixed. They don't have a Mac to test on, and neither do I.
Interprocess communication would be slower, and not worth it because doing it in-process is most likely possible. There is information in the discussion for those other two issues that might provide hints for what needs to be done to fix this problem with this library.
vsquared commentedon Jun 8, 2024
The following runs on my Mac (Sonoma 14.4.1, Intel). The code was run in a Thonny editor with PyObjc plugin.