• Post Reply Bookmark Topic Watch Topic
  • New Topic

Loading a simple class file on JVM startup  RSS feed

 
Nilesh Dhiman
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can we load a simple java class file on JVM startup. In case of a web application, we can use the <load-on-startup> option. But what if we want to load just a single java class when the JVM starts.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a main method and call it. Or use a static initializer block.
 
Campbell Ritchie
Marshal
Posts: 56585
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean Class.forName("pack1.pack2.Foo"); ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!