Java: Call a main method from a main method in another class <p>I have a set of Java files in the same package, each having main methods. I now want the main methods of each of the classes to be invoked from another class step by step. One such class file is Splitter.java. Here is its code. </p> <pre><code>public static void main(String[] args) throws IOException { InputStream modelIn = new FileInputStream("C:\\Program Files\\Java\\jre7\\bin\\en-sent.bin"); FileInputStream fin = new FileInputStream("C:\\Users\\dell\\Desktop\\input.txt"); DataInputStream in = new DataInputStream(fin); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine = br.readLine(); System.out.println(strLine); try { SentenceModel model = new SentenceModel(modelIn); SentenceDetectorME sentenceDetector = new SentenceDetectorME(model); String sentences[] = sentenceDetector.sentDetect(strLine); System.out.println(sentences.length); for (int i = 0; i &lt; sentences.length; i++) { System.out.println(sentences[i]); } } catch (IOException e) { e.printStackTrace(); } finally { if (modelIn != null) { try { modelIn.close(); } catch (IOException e) { } } fin.close(); } } </code></pre> <p>I now want this to be invoked in <code>AllMethods.java</code> inside a main method. So how can I do this? There are several other class files having main methods with <code>IOException</code> which have to be invoked in <code>AllMethods.java</code> file.</p> <p>Update - </p> <p>I have main methods having <code>IOException</code> as well as main methods not having <code>IOEXception</code> that has to be invoked in <code>AllMethods.java</code>. </p>