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 Changing main class so it can be called from a another main class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Changing main class so it can be called from a another main class" Watch "Changing main class so it can be called from a another main class" New topic
Author

Changing main class so it can be called from a another main class

thomas colding
Ranch Hand

Joined: Mar 23, 2007
Posts: 60
I have a Class that trows a exception, but i Would like to call it from a another main Class, and it still have to trow a exception.

The following Class is that I would like to have changed.

public static void main(String[] args)
throws ParserConfigurationException, SAXException,
IOException, XPathExpressionException {

}


thanks in advance
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11152
    
  16

What have you tried, and what happened when you did?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Max Rahder
Ranch Hand

Joined: Nov 06, 2000
Posts: 177
public static void main(String[] args) is a method like any other. Any method in any class can reference it via YourClassName.main(), passing either a String[] or null, depending on what's in main. If you want to know about exception handling, there are lots of posts to this forum, and other sources of information, that explain the syntax options when calling a method that is declared to throw exceptions.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

m iq wrote:


Please check your private messages for an important administrative matter


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Changing main class so it can be called from a another main class
 
Similar Threads
Java I/O
Can a main() method of class be invoked in another class
WHy does main() work with private accessibility?
exception declaration
throwing exceptions