aspose file tools*
The moose likes Java in General and the fly likes Can a JAVA program run 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
Reply locked New topic
Author

Can a JAVA program run without a main method()?

Hari Dhanakoti
Greenhorn

Joined: Jan 04, 2007
Posts: 6
Here is the piece of code which runs without a main function.
Help me in this problem

class EndNow
{
public void p()
{
System.out.println("It also........");
}

}

class MainLess
{
static
{
System.out.println("hi it worked ");
EndNow e = new EndNow();
e.p();
System.exit(0);
}
}


Regards<br />Hari
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Please stop asking the same question in different forums. Continue the conversation there :
http://www.coderanch.com/t/407561/java/java/Do-Java-program-run-without


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can a JAVA program run without a main method()?