This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can a JAVA program run without a main method()?