Min. ports needed for headless AWT/Swing

matthew at FreeBSD.org matthew at FreeBSD.org
Wed Jul 1 14:03:43 UTC 2020


On 01/07/2020 13:56, Aryeh Friedman wrote:
> On Wed, Jul 1, 2020 at 8:54 AM Ronald Klop <ronald-lists at klop.ws> wrote:
> 
>>
>>
>> *Van:* Aryeh Friedman <aryeh.friedman at gmail.com>
>> *Datum:* woensdag, 1 juli 2020 14:36
>> *Aan:* Ronald Klop <ronald-lists at klop.ws>
>> *CC:* freebsd-java at freebsd.org, Michael Osipov <1983-01-06 at gmx.net>
>> *Onderwerp:* Re: Min. ports needed for headless AWT/Swing
>>
>>
>>
>> On Wed, Jul 1, 2020 at 8:30 AM Ronald Klop <ronald-lists at klop.ws> wrote:
>>
>>>
>>> Van: Aryeh Friedman <aryeh.friedman at gmail.com>
>>> Datum: woensdag, 1 juli 2020 14:03
>>> Aan: Ronald Klop <ronald-lists at klop.ws>
>>> CC: freebsd-java at freebsd.org, Michael Osipov <1983-01-06 at gmx.net>
>>> Onderwerp: Re: Min. ports needed for headless AWT/Swing
>>>>
>>>>
>>>>
>>>> On Wed, Jul 1, 2020 at 7:58 AM Ronald Klop <ronald-lists at klop.ws>
>>> wrote:
>>>>>
>>>>>
>>>>> Van: Aryeh Friedman <aryeh.friedman at gmail.com>
>>>>> Datum: woensdag, 1 juli 2020 13:33
>>>>> Aan: Ronald Klop <ronald-lists at klop.ws>
>>>>> CC: freebsd-java at freebsd.org, Michael Osipov <1983-01-06 at gmx.net>
>>>>> Onderwerp: Re: Min. ports needed for headless AWT/Swing
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 1, 2020 at 5:52 AM Ronald Klop <ronald-lists at klop.ws>
>>> wrote:
>>>>>>>
>>>>>>> Van: Aryeh Friedman <aryeh.friedman at gmail.com>
>>>>>>> Datum: maandag, 29 juni 2020 20:59
>>>>>>> Aan: Michael Osipov <1983-01-06 at gmx.net>
>>>>>>> CC: freebsd-java at freebsd.org
>>>>>>> Onderwerp: Re: Min. ports needed for headless AWT/Swing
>>>>>>>>
>>>>>>>> On Mon, Jun 29, 2020 at 2:28 PM Michael Osipov <1983-01-06 at gmx.net>
>>> wrote:
>>>>>>>>
>>>>>>>>> Am 2020-06-29 um 17:43 schrieb Aryeh Friedman:
>>>>>>>>>> I have a java application that works fine with setenv DISPLAY
>>> :0.0 on my
>>>>>>>>>> desktop FreeBSD 12.1 (amd64) [with Xfce4] but when I attempt to
>>> run the
>>>>>>>>>> same app on a VM that has the minimum ports needed to install
>>> OpenJDK 8
>>>>>>>>> and
>>>>>>>>>> Tomcat I get an exception saying that it can't connect to the X
>>> server
>>>>>>>>> even
>>>>>>>>>> though I did setenv DISPLAY desktop:0.0 (and xhost + on the
>>> desktop).
>>>>>>>>>> Note it is the same user on both machines (NIS/NFS password
>>> DB/home dirs)
>>>>>>>>>> doing the running on both machines but is a different user then
>>> the one
>>>>>>>>>> logged in at the console (I do all my development in a separate
>>> account)
>>>>>>>>>
>>>>>>>>> Are you look for "-Djava.awt.headless=true"?
>>>>>>>>>
>>>>>>>>
>>>>>>>> Since this is a screen capture/recording program (which I am the
>>> developer)
>>>>>>>> I need to be able to capture the console (running X) that I am
>>> currently
>>>>>>>> on.   So the question is what is the minimum set of ports/packages
>>> I need
>>>>>>>> to install on the VM to make it see and X server?   It should be
>>> noted the
>>>>>>>> program has no GUI but does use java.awt.Robot#createScreenCapture
>>> (using
>>>>>>>> the full screen resolution as it's bounds) individual frames of the
>>> longer
>>>>>>>> video.
>>>>>>>>
>>>>>>>> Here is the specific exception I am attempting to fix:
>>>>>>>> On desktop (192.168.11.20)
>>>>>>>> % xhost +
>>>>>>>>
>>>>>>>> On VM (192.168.11.4):
>>>>>>>> % setenv DISPLAY 192.168.11.20:0.0
>>>>>>>> % java
>>>>>>>>
>>> -javaagent:/usr/local/share/java/classes/jacocoagent.jar=destfile=/usr/home/aryeh/fnwe-scap-1a1.C036/jacoco.exec,jmx=true,excludes=thistest/*:test/*
>>>>>>>> -cp
>>>>>>>>
>>> /usr/home/aryeh/fnwe-scap-1a1.C036/scrap/www/WEB-INF/lib/fnwe-scap-1a1.jar:/usr/local/share/java/classes/thisTest.jar:/usr/local/share/java/classes/pcCommon.jar:/usr/local/share/java/classes/pcUtil.jar
>>>>>>>> test.TestMain
>>>>>>>>
>>>>>>>> Result of the jvm invocation on the VM (not it works no problem
>>> su(do)'ing
>>>>>>>> to another account on the desktop if I do setenv DISPLAY :0.0):
>>>>>>>>
>>>>>>>> Caused by: java.awt.AWTError: Can't connect to X11 window server
>>> using
>>>>>>>> '192.168.11.20:0.0' as the value of the DISPLAY variable.
>>>>>>>> at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
>>>>>>>> at
>>> sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
>>>>>>>> at
>>> sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
>>>>>>>> at java.security.AccessController.doPrivileged(Native Method)
>>>>>>>> at
>>> sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
>>>>>>>> at java.lang.Class.forName0(Native Method)
>>>>>>>> at java.lang.Class.forName(Class.java:264)
>>>>>>>> at
>>> java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
>>>>>>>> at
>>>>>>>>
>>> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
>>>>>>>> at test.scap.TestVideoFrame.testCaptureFrame(TestVideoFrame.java:76)
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>>> freebsd-java at freebsd.org mailing list
>>>>>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java
>>>>>>>>> To unsubscribe, send any mail to "
>>> freebsd-java-unsubscribe at freebsd.org"
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org
>>>>>>>> _______________________________________________
>>>>>>>> freebsd-java at freebsd.org mailing list
>>>>>>>> https://lists.freebsd.org/mailman/listinfo/freebsd-java
>>>>>>>> To unsubscribe, send any mail to "
>>> freebsd-java-unsubscribe at freebsd.org"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Can you start any other X application on the VM using the DISPLAY
>>> setting? Like /usr/ports/x11/xeyes. Than you know if it is something with X
>>> instead of something with Java. I guess it is something with X.
>>>>>>> I guess your desktop is not listening for external connections to
>>> the X server or your routing between the VM and the desktop does not work.
>>>>>>> Or start a X server in the VM and use DISPLAY=:0.0 again.
>>>>>>
>>>>>>
>>>>>> Don't have any X components installed except for the ones required by
>>> "make/make install" on openjdk8.   The reason for this post in the first
>>> place was to figure out the minimum set of ports needed to get a working
>>> DISPLAY variable in the first place.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org
>>>>>
>>>>> I'm 99% sure you don't need any additional ports to get a working
>>> DISPLAY variable.
>>>>>
>>>>> It will probably help to start your X server with "-listen tcp". But I
>>> don't have enough information to be sure about that and how to configure
>>> that in your setup.
>>>>
>>>>
>>>> I think that might work if in fact there was an X server on the VM:
>>>>
>>>> root at dnixon:~ # X -listen-tcp
>>>> X: Command not found.
>>>> root at dnixon:~ # ls /usr/local/bin/X*
>>>> ls: No match.
>>>> root at dnixon:~ # ls /usr/local/bin/x*
>>>> /usr/local/bin/x265 /usr/local/bin/xicclu /usr/local/bin/xmlcatalog
>>> /usr/local/bin/xslt-config
>>>> /usr/local/bin/xaegis /usr/local/bin/xjc /usr/local/bin/xmlcatmgr
>>> /usr/local/bin/xsltproc
>>>> /usr/local/bin/xft-config /usr/local/bin/xkbcomp /usr/local/bin/xmllint
>>> /usr/local/bin/xsubpp
>>>> /usr/local/bin/xgettext /usr/local/bin/xml2-config /usr/local/bin/xmlwf
>>> /usr/local/bin/xxd
>>>> root at dnixon:~ # ls /usr/local/sbin/x*
>>>> ls: No match.
>>>> root at dnixon:~ # ls /usr/local/sbin/X*
>>>> ls: No match.
>>>> root at dnixon:~ # java -version
>>>> openjdk version "1.8.0_252"
>>>> OpenJDK Runtime Environment (build 1.8.0_252-b09)
>>>> OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
>>>>
>>>>
>>>> --
>>>> Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org
>>>
>>> In an earlier message you talked about "setenv DISPLAY 192.168.11.20:0.0".
>>> That is the IP address of your desktop. So the X server must be running on
>>> your desktop.
>>>
>>> You want the VM to screencapture the screen of the desktop? Or do you
>>> want the VM to screencapture the screen of the VM?
>>
>>
>> On the desktop... finally got it to capture the screeen on the desktop via
>> what I tried above but now have a second problem with is the audio capture
>> is there anyway to make the following Java snippet work with a remote mic
>> (works fine on the desktop with a local mic on dsp2.0)?
>>
>>                  fmt=new AudioFormat(160000,8,2,true,true);
>>                  mic=AudioSystem.getTargetDataLine(fmt);
>>                  mic.open(fmt);
>>                  mic.start();
>> --
>> Aryeh M. Friedman, Lead Developer, http://www.PetiteCloud.org
>>
>>
>> Good that it is solved. Would you mind sharing what the solution was?
>>
> 
> Adding -- -listen tcp to my call to startx on the desktop (I was confused
> about which machine was the server and which was the client since the
> relationship is reverse of the normal order.... i.e. the server is the
> local machine and the client is the remote one not the other way around for
> X)
> 
> 

Be aware that running remote X applications against a local X server 
will transmit all of the X related traffic across the network in the 
clear -- which is roughly as bad as running old-style rsh(1).

That may or may not be a problem for your use case, but in general look 
into tunnelling your X traffic across an SSH session -- see the 
description of the  `-X` and `-Y` flags in ssh(1).  SSH basically sets 
up a port forwarding from the loopback on the (remote) X client to the 
(local) X server on your desktop, and will set DISPLAY and XAUTHORITY to 
appropriate values for you automatically.  Plus you don't need to enable 
a tcp listener for X, which in itself just offers up a massively 
enlarged attack surface.

	Cheers,

	Matthew


More information about the freebsd-java mailing list