Java jar run only once -
singleton using:
    public class singleton {         private static singleton singleton = new singleton( );         /* private constructor prevents other          * class instantiating.         */        private singleton(){ }         /* static 'instance' method */        public static singleton getinstance( ) {       return singleton;    }    /* other methods protected singleton-ness */    protected static void demomethod( ) {        new newjframe().setvisible(true);    } }   newjframe main:
   public static void main(string args[]) {          /* set nimbus , feel */          * details see ht         /* create , display form */         java.awt.eventqueue.invokelater(new runnable() {             public void run() { //                new newjframe().setvisible(true);                 singleton tmp = singleton.getinstance( );                 tmp.demomethod();             }         });        }   i want 1 jar.
not want jar. see: http://i.stack.imgur.com/5lpjc.png
my english bad sorry.
i solved :d
newjframe main change it:
public static void main(string args[]) {          /* set nimbus , feel */          * details see ht         /* create , display form */         java.awt.eventqueue.invokelater(new runnable() {             public void run() { //              new newjframe().setvisible(true);                 serversocket once;                 singleton singleton;                  try {                     once = new serversocket(1334);                     singleton.getinstance().demomethod();                  } catch (ioexception e) {                     // todo auto-generated catch block                     e.printstacktrace();                     joptionpane.showmessagedialog(null, "already open");                 }             }         });        }        
Comments
Post a Comment