“could not find or load main class” error in windows 7 with compiled ubuntu jar-Collection of common programming errors

This error usually shows up when you don’t include the current directory (.) in the classpath.

If there are any external libraries that you specify when starting the program, then you probably do something like java -jar -classpath dir/library.jar program.jar. Instead, add . to the classpath: java -jar -classpath .;dir/library.jar program.jar

Other possibilities are:

  • you didn’t include a Manifest in the JAR
  • in the Manifest that you did include, you didn’t specify which is the main class, or you did it wrong.