File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to run a normal java program without main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to run a normal java program without main method" Watch "how to run a normal java program without main method" New topic
Author

how to run a normal java program without main method

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Is it possible to run a program(a method) without a main method?


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
PrasannaKumar Sathiyanantham
Ranch Hand

Joined: Nov 12, 2009
Posts: 110
i dont think so........

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

and servlets and jsps(of course even they have a init() method similar to applets)


To err is human,
To forgive is not company policy
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

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

Joined: Nov 12, 2009
Posts: 110
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

Joined: Aug 29, 2008
Posts: 580

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

Joined: Jul 26, 2007
Posts: 10376
    
    8

Notice the SeleneseTestCase
Google for JUnit TestCase and TestSuite


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41863
    
  63
Most likely Eclipse understands all about JUnit, and thus executes it as a test case. Consult the Eclipse documentation about its JUnit integration.


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

Joined: Oct 27, 2005
Posts: 19695
    
  20

PrasannaKumar Sathiyanantham wrote:i dont think so........

It is possible with static initializers but it's cheating:


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11314
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Monu Tripathi
Rancher

Joined: Oct 12, 2008
Posts: 1369
    
    1

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.


[List of FAQs] | [Android FAQ] | [Samuh Varta]
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174

Sure, yes. Compile your programm and then run it from other program that has main method.
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
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.


Thanks, leo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to run a normal java program without main method