Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Running a class from command line

 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic