How can I run a Java GUI application on a headless Linux that does not support GUI?
Asked Answered
C

4

7

I have created a Java GUI application that is running in Windows. Now I want it to run it on a headless Linux instance that does not support GUI. I wanted to convert the GUI to TUI. Is there a way I can substitute some classes and make it run in Linux by TUI. Please help.

Cohabit answered 14/7, 2012 at 6:59 Comment(2)
pitman.co.za/projects/charva/index.htmlAscetic
@PeterMmm: Please consider making this an answer.Crooked
G
4

You can use PeterMmm's suggestion http://www.pitman.co.za/projects/charva/index.html

Or, you can run the GUI on your local machine by running an X server, then connecting to the Linux box using ssh -X. That will show the GUI on your local machine, but the program is actually running on the linux box.

Or, you can run XVFB to fake a GUI on the Linux box. You won't be able to see the GUI or interact with it in any way, but that might not matter to you.

Gramme answered 14/7, 2012 at 8:53 Comment(0)
K
4

For the sake of spreading a simple and effective solution, I copy the answer provided by @fossfreedom on SA "Ask Ubuntu":

sudo apt-get install xvfb

then:

xvfb :1 -screen 0 800x600x8 &
export DISPLAY=":1"
java application_name.jar

or

xvfb-run -a -e /tmp/some/log/file.log java -jar /home/user/somejava.jar

-> see: https://askubuntu.com/questions/50599/how-do-you-run-a-gui-application-without-gui-gui-application-as-daemon-on-headl

Kallick answered 6/3, 2019 at 15:51 Comment(0)
A
1

There are some ncurses implementations for Java available like this one: http://www.pitman.co.za/projects/charva/index.html

Ascetic answered 16/7, 2012 at 8:13 Comment(0)
I
0

If you are connecting from another X running Linux machine put following to your user ssh config (~/.ssh/config):

Compression yes
CompressionLevel 9
ForwardX11 yes
ForwardX11Trusted yes

Then when you login to remote Linux machine your GUI going to be forwarded to local screen. Note that it could be slow... notably some AWT applications are really slow even on LAN.

If on Windows, intall CygWin and its Xserver components. Also OpenSSH can be helpful. When you going to connect through CygWin's ssh, use the same config as above. Of course run Xserver prior connecting to remote machine. You also can use Putty to connect to remote, but don't forget to enable X11 forwarding and compression in session config.

Remote machine must have xauth installed + sshd must have X11Forwarding enabled. If OK echo $DISPLAY will show localhost:10.

Ivy answered 14/7, 2012 at 21:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.