我是 NetBeans 的新手。我无法在 Eclipse 中运行它。当我尝试运行它时,我收到一个错误,例如non static variable cannot be referenced from static context
. 请帮我解决。
InetAddress ip;
try {
ip = InetAddress.getLocalHost();
String t1= ip.getHostName();
sysname.setText(t1); // HERE IS THE ERROR
//sysname.setText("hi"); // EVEN THIS ALSO MAKE ERROR
} catch (UnknownHostException ex) {
Logger.getLogger(mainframe.class.getName()).log(Level.SEVERE, null, ex);
}