• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to run a normal java program without main method

 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to run a program(a method) without a main method?
 
PrasannaKumar Sathiyanantham
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont think so........

it is possible in applets........

and servlets and jsps(of course even they have a init() method similar to applets)
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to find out how the following programs runs... I mean the sequence...




The programs runs
The method testSampleFlex() executes !!
 
PrasannaKumar Sathiyanantham
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this a java program or adobe flex program...

did you try this in a IDE like eclipse(if so copy it and try to execute manually...ie command prompt)

even if it runs then
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually this is done using Eclipse. And i am try to find out how to run this in command prompt(by putting all the lib files in the correct floder).

 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notice the SeleneseTestCase
Google for JUnit TestCase and TestSuite
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most likely Eclipse understands all about JUnit, and thus executes it as a test case. Consult the Eclipse documentation about its JUnit integration.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PrasannaKumar Sathiyanantham wrote:i dont think so........

It is possible with static initializers but it's cheating:
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12100
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say that there is no such thing as a "normal" java program without a main method. "Normal" means that something is standard, or not unusual. You're trying to do something distinctly NOT normal.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:I would say that there is no such thing as a "normal" java program without a main method. "Normal" means that something is standard, or not unusual. You're trying to do something distinctly NOT normal.

I second that.
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure, yes. Compile your programm and then run it from other program that has main method.
 
leo donahue
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use a static block that does whatever you want your program to do, i.e. create a form, output something.

This is not recommended because you are now writing structured code, not OO code, why use Java at all at this point.

Rats, sorry Rob, I skimmed by your post. Excuse me.
 
hector montero
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


//coco
//Command line
//java -Djava.security.manager=com.test.Test
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

That is an old‑fashioned way to try that; it worked until Java6 but won't work in Java7 or Java8.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic