2

I have built an application using Swing and exported it as runnable jar file and converted it to .exe file. Its working fine in some systems, but in other systems a popup error is shown up saying "The main startup class could not be found" and the application exits.

Has anyone faced this kind of problem?

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Srujan Simha
  • 135
  • 1
  • 3
  • 8
  • Did you try running the exported jar *before* converting it to an `.exe` file? That would at least tell us at *which step* the problem is. Also: have you set the `CLASSPATH` environment variable on your system? – Joachim Sauer Apr 11 '13 at 11:50
  • I had this problem too. I had made my project with java8 but I switch to java7 during work. So, You try to create a new project and clean and build it again. Now, try to create .exe again. – ParisaN Mar 11 '18 at 09:00

2 Answers2

1

Please check your generated Manifest file for classpath.

Check this link..."Could not find the main class" when double-clicking .jar file

Community
  • 1
  • 1
ashwinsakthi
  • 1,856
  • 4
  • 27
  • 56
  • This is what my MANIFEST.MF file has `Manifest-Version: 1.0 Class-Path: .` ...and I included a line `Main-Class: mypackage.myclass` but still im getting the same error...any idea? – Srujan Simha Apr 11 '13 at 09:25
  • `Class-Path: .` means it will search for classes based on the local directory. That's a **bad idea**! The jar file itself should contain all required classes and resources! Also, please *update your question* when you add new information, don't just add it as a comment to random answers! – Joachim Sauer Apr 11 '13 at 13:27
1

You need to compile at the same level you specify in Jar2Exe.

In Eclipse, right click the project > properties > Java Compiler > JDK Compliance > 1.6 (for instance).

Then, specify 1.6 as the minimum required when you build the .exe file.

Dale
  • 5,520
  • 4
  • 43
  • 79