aspose file tools*
The moose likes Java in General and the fly likes Program without a main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Program without a main method" Watch "Program without a main method" New topic
Author

Program without a main method

Anshul Kapoor
Greenhorn

Joined: Apr 09, 2010
Posts: 5

Is there any other way of creating a program without a main method ?
public class Test{
static{
System.out.println("Without a Main Method");
System.exit(1);

}
}
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42916
    
  68
Depends on what your definition of "program" is. What you posted would not fit my definition of "program", but it is a Java class that can be executed without having a main method, yet still executes some code.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

And welcome to the Ranch!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Program without a main method