wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Running a class from command line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running a class from command line" Watch "Running a class from command line" New topic
Author

Running a class from command line

Neelima Mohan
Greenhorn

Joined: May 23, 2010
Posts: 27
Hi,

Is there a way to run a java class (which doesnt have a main method) and access its object, methods etc from the command line?

Thanks,
Neelima
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Yes, but you'll have to create a class that has a main method, and then in the main method create an object of the class of interest. When I do this, I often have the word "Test" in my small main method containing class. So if my original class is called Fubar, the testing class will be FubarTest or some such.

Much luck!
Neelima Mohan
Greenhorn

Joined: May 23, 2010
Posts: 27
Thanks :-)
 
wood burning stoves
 
subject: Running a class from command line
 
Similar Threads
Trying to run my first program: java.lang.NoClassDefFoundError
Complex Number
[solved]when i run file,promt message "Class "lab4.que1" does not have a main method."why?
exchange jessDE
Read arguments from .csh file which is in next line thru Java class