I have 2 .java files called model.java and table.java

I have 3 class files, model.class, table.class and WindowCloser.class (which is in the table.java file).

I've looked online on how to make a jar file, but whenever I try, either nothing happens or it says Main-class not found.

table has the main method.

How do I create an executable jar file?

P.S.: I use eclipse. Is there an easy way?

If you are using Eclipse then thats I guess the most easy way to make a JAR.
Also while making a JAR file in Eclipse you get an option to select the Main Class in the final step. Have you done that ???

Also try running your JAR from the console like this:-

java -jar jar-file-name.jar <path-to-main-class>

where your path to main class is the package hierarchy path in which your main class resides, for ex: if your main class say "Alpha" in package "foo" which is in turn in package "bar", your <path-to-main-class> would be "bar.foo.Alpha".

If this command works correctly it means you JAR is fine only you have specified the manifest file(in the JAR) which should point to your main class.


However I also suggest you try to make a JAR file directly from the console so that you know actually what goes on behind the scenes in Eclipse. You can check out this for JAR file specifications.