how to run a program in telnet
i am trying to run the java program which uses java.awt pack on the telnet.
it gives me the following error
java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the
value of the DISPLAY variable.
at sun.awt.motif.MToolkit.<init>(Compiled Code)
at java.awt.Toolkit.getDefaultToolkit(Compiled Code)
at java.awt.Window.getToolkit(Compiled Code)
at java.awt.Frame.addNotify(Compiled Code)
at java.awt.Window.show(Compiled Code)
at java.awt.Component.show(Compiled Code)
at java.awt.Component.setVisible(Compiled Code)
at startServer.main(Compiled Code)
how to make it run!!!
[688 byte] By [
decaynan] at [2007-9-26 4:11:51]

well,
it seem that you have to precise on wich machine you want to send the visual result of your program.
You have to set a DISPLAY environment variable as :
SET DISPLAY="YOURIPADRESS:0.0"
For example : set display=45.252.12.41:0.0
You have to do this on unix machine with multiple user.
Hopes this will help you.
Jean
how do u do the display setting in the unix m/c
I'm not a Unix specialist but I think you can do it with a runexec() :Process proc = Runtime.getRuntime().exec("set DISPLAY="+(new Socket()).getLocalAddress().toString()+":0.0");Hum..I hopes somebody may have a better idea...Jean.
it does not seem to workthe socket constructor does not ahve this type
you should set the DISPLAY variable in the shell before you start the java process, so in the machine you have telnetted to do this (imagine that the IP address of the machine you are sitting at is 10.0.0.1)
(if you are in a 'C' shell)
setenv DISPLAY 10.0.0.1:0
or if you are in a bash shell
export DISPLAY=10.0.0.1:0
you need to have access to the X server on the machine 10.0.0.1 too, which you can do with the command on the machine you are sitting at
xhost +
Please show me the code of your runexec.
// start server
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class startServer extends Frame implements ActionListener
{
private Button connect,disconnect;
private Label ip,port,status,server;
private TextField iptext,porttext;
private Button bList[] = new Button[2];
private InetAddress address;
public static void main(String[] args)
{
startServer s= new startServer();//create instance of applic.
s.setSize(200,200);
s.setVisible(true);
}
public startServer()//constructor
{
try{
Process proc = Runtime.getRuntime().exec("set DISPLAY="+(new Socket()).getLocalAddress().toString()+":0.0");
}catch(Exception e)
{
System.out.println(e);
}
setTitle("Server");
setLayout(new FlowLayout());
//create button:
connect = new Button("Connect");
disconnect = new Button("Disconnect");
try
{
address = InetAddress.getLocalHost();
}catch(UnknownHostException ue)
{
System.err.println(ue);
}
String add =address.toString();
int split = add.indexOf('/');
//create text fields
iptext = new TextField(add.substring(split+1),15);
porttext = new TextField("1991",10);
//create label
ip = new Label("IP");
port = new Label("Port");
server = new Label(add.substring(0,split));
//adding to the frame
add(ip);
add(iptext);
add(port);
add(porttext);
bList[0] = (Button) add(connect);
bList[1] = (Button) add(disconnect);
add(server);
for(int i = 0; i<2; i++)
{
bList.addActionListener(this);
}
addWindowListener(new MyWindowAdapter());
}
public void actionPerformed(ActionEvent ae) //action performed
{
if(ae.getSource() == bList[0])
{
System.out.println("hi");
}
}
}
class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
The pb of this solution is that it need a static IP addressThe way I proposed use a socket to get the local IP address.Jean.
My mistake :Do not use "set display" but "export display"Old windows habitudes...
OK you can use a socket constructor as I said because it will be created on the server and use the server IP address.Could you put this IP in the args of your program ?
startServer.java:28: No constructor matching Socket() found in class java.net.Socket.Process proc = Runtime.getRuntime().exec("export DISPLAY="+(newSocket()).getLocalAddress().toString()+":0.0");this is the error!!!
I would be amazed if your scheme works. The DISPLAY value is an environment variable that the JVM will use to work out where to display the resulting windows. Using runtime.exec will spawn a child process, and the child process cannot give enviroment variables back to the parent process. As I understand you *must* set the DISPLAY before the JVM starts.
Rob is right,DISPLAY environment variable have to be set before JVM execution.I'm sorry to have spent your time.
Is it possible at all to run a GUI through telnet? I have never seen that, so I would think it would not be possible to run that program even though you set the DISPLAY environment variable, but maybe I'm wrong.
Hey guys!!! Thanx for the thoughts!!! I am still gona try doin it are find out a way to do the GUI come up in telnetD.K
Abnormal,
Yes you are wrong, but if you are used to using MS Windows (TM) products then you probably will never have seen it. There are 3rd party products for Windoze that allow you to display a program on a different computer, but for those of us who are used to using X windows on a UNIX box, this is everyday stuff. You need to be running an X server on your local machine (yes, you can do this on a windows box too using a 3rd party product - Cameleon Software for example). All you need to do is configure you local X server to run in open mode (by typing xhost +) and set the DISPLAY variable (on a different UNIX machine) to point to your local machine. Life with UNIX is just so much more straight forward than all those different Winzlop products...
just my 0.0129
Rob