 <p>As far as I can tell, you can just use the following steps.</p> <ol> <li>Rename <code>main</code> in the second class, and move the code content as a separate method into the first class.</li> <li>Rename <code>main</code> in the first class.</li> <li>Make a new main that will use a command line argument to disambiguate between them.</li> </ol> <p>To be more specific, your code will now look like this:</p> <pre><code>public class Cipher { public static char cipher (int j){ ... } // Old main1 public static void encrypt() { ... } // Old main2 public static void decrypt() { ... } // One possible way to disambiguate, there are many others. public static void main(String[] args) { if (args[0].equals("encrypt") encrypt(); else decrypt(); } } </code></pre> <p>Note that I removed <code>String[] args</code> from your two old mains, because you did not seem to be using them.</p>