Tom
Tom

Reputation: 9653

"could not find or load main class" error in windows 7 with compiled ubuntu jar

I have a simple Swing app compiled with netbeans 7.1.2 on a ubuntu machine which has the java version:

java version "1.6.0_22" OpenJDK Runtime Environment (IcedTea6 1.10.4) (6b22-1.10.4-0ubuntu1~11.04.1) OpenJDK Server VM (build 20.0-b11, mixed mode)

jar works great when i use the shell using "java -jar filename.jar" in linux but in the windows 7 with the java version 1.7.05 i get: "Error: could not find or load main class"

How do i resolve this issue?

Upvotes: 0

Views: 5310

Answers (1)

Radu Murzea
Radu Murzea

Reputation: 10920

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.

Upvotes: 4

Related Questions