You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by Andrew Dalke <da...@dalkescientific.com> on 2020/11/11 10:46:46 UTC

jcc InitVM() creates menu on macOS

Hi all,

  I am trying to use jcc on macOS 10.14.4 (Mojave) to build Python 3.9 bindings for cdk-2.3.jar from https://github.com/cdk/cdk/releases/tag/cdk-2.3 .

I managed to build "pycdk" but when I run initVM() like this, from the Python console:

>>> import pycdk
>>> pycdk.initVM() 

the console freezes while Java opens an empty application UI on macOS titled "bin". The pulldown "About bin" says simply "python".

My guess is that I need to set some Java VM configuration so it doesn't try to connect to the Mac's window manager when it starts up.

I am effectively completely ignorant about Java development, and my searches haven't found a way to do this.

Any pointers?

In case it's relevant, I compiled jcc from svn as of 12 hours ago

>>> pycdk.JCC_VERSION
'3.8'

I compiled Python from source.

I'm using the system Java:

% which java
/usr/bin/java
% ls -l /usr/bin/java
lrwxr-xr-x  1 root  wheel  74 Mar 17  2019 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
% java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

Best regards,

				Andrew
				dalke@dalkescientific.com



Re: jcc InitVM() creates menu on macOS

Posted by Andrew Dalke <da...@dalkescientific.com>.
On Nov 11, 2020, at 21:43, Andi Vajda <va...@apache.org> wrote:
> Add this to initVM's vmargs: '-Djava.awt.headless=true'

That works! Thanks!


				Andrew
				dalke@dalkescientific.com



Re: jcc InitVM() creates menu on macOS

Posted by Andi Vajda <va...@apache.org>.
On Wed, 11 Nov 2020, Andi Vajda wrote:

>
> On Wed, 11 Nov 2020, Andrew Dalke wrote:
>
>> Hi all,
>>
>>  I am trying to use jcc on macOS 10.14.4 (Mojave) to build Python 3.9 
>> bindings for cdk-2.3.jar from 
>> https://github.com/cdk/cdk/releases/tag/cdk-2.3 .
>> 
>> I managed to build "pycdk" but when I run initVM() like this, from the 
>> Python console:
>> 
>>>>> import pycdk
>>>>> pycdk.initVM()
>> 
>> the console freezes while Java opens an empty application UI on macOS 
>> titled "bin". The pulldown "About bin" says simply "python".
>> 
>> My guess is that I need to set some Java VM configuration so it doesn't try 
>> to connect to the Mac's window manager when it starts up.
>> 
>> I am effectively completely ignorant about Java development, and my 
>> searches haven't found a way to do this.
>> 
>> Any pointers?
>
> I don't remember what that parameter is but there is a way to disable AWT 
> when the Java VM starts and it's passed in like any other VM args.
> for example: initVM(vmargs='-Xcheck:jni,-verbose:jni,-verbose:gc')
> You need to find what that argument is (something with awt iirc) and use it
> in the vmargs parameter passed to initVM(), which is empty by default.
> There are *lots* of such arguments, "man java" is a good start.

Found it, it's called headless mode:
   https://www.oracle.com/technical-resources/articles/javase/headless.html

Add this to initVM's vmargs: '-Djava.awt.headless=true'

Andi..

>
> Andi..
>
>> 
>> In case it's relevant, I compiled jcc from svn as of 12 hours ago
>> 
>>>>> pycdk.JCC_VERSION
>> '3.8'
>> 
>> I compiled Python from source.
>> 
>> I'm using the system Java:
>> 
>> % which java
>> /usr/bin/java
>> % ls -l /usr/bin/java
>> lrwxr-xr-x  1 root  wheel  74 Mar 17  2019 /usr/bin/java -> 
>> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
>> % java -version
>> java version "1.8.0_45"
>> Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
>> Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
>> 
>> Best regards,
>>
>> 				Andrew
>> 				dalke@dalkescientific.com
>> 
>> 
>> 
>

Re: jcc InitVM() creates menu on macOS

Posted by Andi Vajda <va...@apache.org>.
On Wed, 11 Nov 2020, Andrew Dalke wrote:

> Hi all,
>
>  I am trying to use jcc on macOS 10.14.4 (Mojave) to build Python 3.9 bindings for cdk-2.3.jar from https://github.com/cdk/cdk/releases/tag/cdk-2.3 .
>
> I managed to build "pycdk" but when I run initVM() like this, from the Python console:
>
>>>> import pycdk
>>>> pycdk.initVM()
>
> the console freezes while Java opens an empty application UI on macOS titled "bin". The pulldown "About bin" says simply "python".
>
> My guess is that I need to set some Java VM configuration so it doesn't try to connect to the Mac's window manager when it starts up.
>
> I am effectively completely ignorant about Java development, and my searches haven't found a way to do this.
>
> Any pointers?

I don't remember what that parameter is but there is a way to disable AWT 
when the Java VM starts and it's passed in like any other VM args.
  for example: initVM(vmargs='-Xcheck:jni,-verbose:jni,-verbose:gc')
You need to find what that argument is (something with awt iirc) and use it
in the vmargs parameter passed to initVM(), which is empty by default.
There are *lots* of such arguments, "man java" is a good start.

Andi..

>
> In case it's relevant, I compiled jcc from svn as of 12 hours ago
>
>>>> pycdk.JCC_VERSION
> '3.8'
>
> I compiled Python from source.
>
> I'm using the system Java:
>
> % which java
> /usr/bin/java
> % ls -l /usr/bin/java
> lrwxr-xr-x  1 root  wheel  74 Mar 17  2019 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
> % java -version
> java version "1.8.0_45"
> Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
> Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
>
> Best regards,
>
> 				Andrew
> 				dalke@dalkescientific.com
>
>
>