java - Unable to change JLabel value -
i'm new netbeans. unable run in eclipse. when try run error non static variable cannot referenced static context. please me solve.

inetaddress ip; try { ip = inetaddress.getlocalhost(); string t1= ip.gethostname(); sysname.settext(t1); // here error //sysname.settext("hi"); // make error } catch (unknownhostexception ex) { logger.getlogger(mainframe.class.getname()).log(level.severe, null, ex); }
from exception you've posted, seems code you've shown in static method, maybe main(), while variable sysname instance variable, possibly declared as
private jlabel sysname; you cannot access instance field without instance, ie static context.
Comments
Post a Comment