File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Only one instance of class should be creatred

 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way in JAVA so that only one instance can be created of an application?
 
Ganesan Ponnusamy
MyExamCloud Support
Ranch Hand
Posts: 264
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use singleton pattern to achieve the same.

Typical example:



You can also implement singleton pattern in Java by using Enums.
 
Stephan van Hulst
Bartender
Pie
Posts: 4846
34
Chrome Netbeans IDE Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The original poster probably wants one instance of the application, not of a class.

Take a look at this article: http://www.rbgrn.net/content/43-java-single-application-instance
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks stephan !
 
Mike Okri
Ranch Hand
Posts: 83
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may also want to take a look at the free JUnique library.
 
Laxmikant Kumbhare
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Okri wrote:You may also want to take a look at the free JUnique library.



What is it?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Laxmikant Kumbhare wrote:
Mike Okri wrote:You may also want to take a look at the free JUnique library.



What is it?


Click the link and find out.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic