0

So. I compile a .jar file. I know I have the Manifest correct. The main class is called "Boot." Whenever I try to run the .jar, I get the following error: Could not find the main class: <classdir>.Boot. Program will exit. I have no idea what is causing it. Also, I found something strange: If I open the file with 7-zip (alternative to WinZip) and navigate to the main class, there isn't a file called Boot.class. There are two files: Application.class and Application$1.class. Does anyone have an idea as to what is happening and how to fix? :\

EDIT I just realized that there was another .java in the directory as Boot.java was called Aplication.java. So I guess Boot.java just isn't getting compiled? :\

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    How are you creating the jar? - By the way, it's a bad idea to have classes in the default package (that is classes that don't have a package statement at the top). – MeBigFatGuy Apr 26 '11 at 02:47
  • What IDE are you using? Did you set the main class in the project properties? – travega Apr 26 '11 at 02:49
  • 1
    "I know I have the Manifest correct." 1) At this stage, that is a rash assumption. 2) Please *always* copy/paste compile & run-time error messages. 3) When you do that, make sure they are 'code formatted' using either the ` character (for in-line code formatting) or the `{}` button for code blocks. I am guessing that most people did not realize that class name had a `` package! 4) Class names that include the $ symbol generally mean anonymous inner classes are declared. 5) Manifest files must end in a blank line. Make sure yours has one. – Andrew Thompson Apr 26 '11 at 03:00
  • It's a joined project over Github. Compiling the .jar has always worked before though... look below, I posted a dummy version of the Manifest. I have no compile errors. It compiles fine. As I said, look below. There's nothing wrong with the manifest. I'm just using to shorten the blah.blah.blah.Boot.java. The manifest file does have a blank line at the bottom – anonymous Apr 26 '11 at 03:00
  • This "Main-Class: .Boot" is not correct. – Thorbjørn Ravn Andersen Apr 26 '11 at 05:55
  • Are you sure your manifest is correct? Assume it is correct, and if Boot.class is the main class, are you sure you build your jar properly? – anta40 Apr 26 '11 at 02:48
  • I know that the manifest is correct. `Main-Class: .Boot Name: org/rsbot Sealed: true Specification-Title: "blah" Specification-Vendor: "org.blah" Implementation-Title: "blah" Implementation-Vendor: "org.blah"` – anonymous Apr 26 '11 at 02:49
  • Which class have the main() method()? – anta40 Apr 26 '11 at 02:57
  • Boot.java has `public static void main(String[] args) throws IOException {` – anonymous Apr 26 '11 at 02:59
  • Then build Boot.java, and the rest will follow. And when you're going to build the jar, make sure all the required classed are specified. – anta40 Apr 26 '11 at 03:02

1 Answers1

1

You should check if any of these work:

  • "java -jar your.jar Boot"
  • unpack the jar file (any unzip will work), cd into the root folder, and run it with "java Boot"

This will tell you if the Manifest was wrong or the Boot.java wasn't there. Then fix as appropriate.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347