hi!
this doesn't work!
you can start this app twice (it's because there are different jvms with
different classloaders involved), though Main is a singleton:

import javax.swing.*;
import java.awt.*;

public class a {

 public static void main(String [] argv) {
  Main m = Main.getInstance();
  if (m!=null)
   m.start();
  else
   System.out.println("Main already running!");
 }

}

final class Main {

 final static private Main m = new Main();
 static int cnt=0;

 private Main() { }

 public static Main getInstance() {
  if (cnt==0) {
   cnt+=1;
   return m;
  } else
   return null;
 }

 public void start() {
  new Application();
 }
}

class Application extends JFrame {

 public Application() {
  super();
  setDefaultCloseOperation(EXIT_ON_CLOSE);
  setSize(300,300);
  setVisible(true);
  validate();
 }
}

-mw

----- Original Message -----
From: "Ramesh RGVS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 20, 2002 1:13 PM
Subject: Re: batch file


> Hi Sudhir
>    Here you can use singleton pattern.Make the class
> which ur trying to invoke from batch file follow a
> singletonpattern.Hope this will solve ur problem
>
> Regards
> Ramesh
>
>
>
> --- Sudhir Kumar <[EMAIL PROTECTED]> wrote:
> >  hi,
> >         i have a an application which runs when i
> > click on a batch file. But my
> > problem is, once i click on the batch file and the
> > application starts
> > running, the user can come back and click on this
> > batch file again to create
> > another instance of this application. How can i stop
> > this ??
> >
> > Thanks in advance.
> > SKN
> >
> >
>
___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED]
> > and include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
> >
> http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
> >
> http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help:
> > http://www.lsoft.com/manuals/user/user.html
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> LAUNCH - Your Yahoo! Music Experience
> http://launch.yahoo.com
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to