kev.a
kev.a

Reputation: 33

Launch java program from ssh

I have a simple java program with a Dialog Box

String s = (String)JOptionPane.showInputDialog(
                    frame,
                    "Complete the sentence:\n"
                    + "\"Green eggs and...\"",
                    "Customized Dialog",
                    JOptionPane.PLAIN_MESSAGE,
                    icon,
                    possibilities,
                    "ham");

If I launch the program from the Raspbian terminal the Dialog Box appear, but if I connect to the Raspbian with SSH from my macbook and I launch the program from there the Dialog Box doesn't appear. What could be the problem ?

Upvotes: 0

Views: 118

Answers (1)

Thomas Stets
Thomas Stets

Reputation: 3043

When you use a ssh you just have a terminal, i.e. it displays characters. You need to use X11. This will allow you to display windows and graphics from a remote computer.

You need:

  • a X11 server on your mac (this may sound a bit confusing, but it provides the service of displaying graphics). X11 used to be part of OS X, but is no longer. It can be installed from here: https://www.xquartz.org/

  • open an X11 terminal and enable X11 access from remote hosts (see man page of xhostcommand. Shortest way is xhost + to allow access from anywhere, but this is very bad security unless you are safely behind a firewall in an environment where you trust all machines)

  • allow x11Forwarding on the ssh server side (see https://unix.stackexchange.com/questions/12755/how-to-forward-x-over-ssh-from-ubuntu-machine )

  • open your ssh connection with x11Forwarding enabled: ssh -X your-server

Upvotes: 1

Related Questions