简体   繁体   中英

Cannot find or load main class from .jar file

So I wrote a project in Eclipse and when I click on the green run button it works fine. When I export it into a jar and I double click on it a quick command prompt appears saying "cannot find or load main class...". I tried everything. I tried renaming registry keys, reinstalling java, changing environment variables and of course turning it on and off again. I read all the other threads on stack and tried everything they suggested. Here is my Manifest file:

Manifest-Version: 1.0
Class-Path: .
Main-Class: main.Main

My Main class is in a package called main.

  1. I'd like to suggest to change the package name into something other than main .
  2. don't forget to make a run configuration, which specifies the name of your main class.
  3. package all the related other jar files into the same package.
  4. run the executable.jar as java -jar YourExecutable.Jar

And if it does not solve your problem, just see my MANIFEST.MF file in my Executable jar file. Maybe it can give you some clue.

Manifest-Version: 1.0
Rsrc-Class-Path: ./ concurrentlinkedhashmap-lru-1.2.jar slf4j-api-1.7.
 5.jar org.simpleframework.jar openflowj-0.3.7-SNAPSHOT.jar mongo-java
 -driver-2.11.2.jar netty-3.9.0.Final.jar guava-15.0.jar org.restlet.e
 xt.jackson.jar logback-classic-1.0.13.jar joda-time-2.2.jar org.codeh
 aus.jackson.core.jar org.codehaus.jackson.mapper.jar openflowj-0.3.7-
 SNAPSHOT-sources.jar org.restlet.jar logback-core-1.0.13.jar org.rest
 let.ext.slf4j.jar org.restlet.ext.simple.jar openflowj-0.3.7-SNAPSHOT
 -javadoc.jar
Class-Path: .
Rsrc-Main-Class: etri.sdn.controller.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM