wood burning stoves 2.0*
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
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: 41116
    
  45
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.


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

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
 
Similar Threads
Do Java program can run without main function()? If not please solve this problem
thread without main( String arg[])
Error: Exeption in thread "main" java.lang.NoSuchMethodError: main
how to run a normal java program without main method
can a program without "main" method show output?