No manifest file Eclipse

jtrose7 :

They've send me a java code (written with Eclipse) that came in a zip. When decompressed, I had the following files:

- .settings
  - org.eclipse.jdt.core.prefs
- bin
  - anon
     - Discovery.class
     - Main$1.class
     - Main.class
     - Server.class
- src
 - anon
     - Discovery.java
     - Main.java
     - Server.java
- .classpath
- .project
- jssc.jar

When I try to execute the jssc.jar from the command line, I get a message saying no main manifest attribute. I have decompressed the jar file to see the manifest and what it contained:

  • jssc: with lots of "class" files inside
  • libs: with folders containing files for each OS
  • META-INF: with a file manifest

So, it seems that there is a manifest. However, when I open it appears:

    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.8.1
    Created-By: 1.6.0_45-b06 (Sun Microsystems Inc.)
    X-COMMENT: Main-Class will be added automatically by build

What should I do? How do I add the jar file to buildpath?

Ioannis Barakos :

If you tried to execute it with the command: java -jar jssc.jar and it failed try to use the following command

java -cp jssc.jar anon.Main

The above will tell JVM to load jssc.jar in its classpath and then execute the main method in Main class.

Update: if the java program needs more classes than the classes exist in jssc.jar add them in the -cp option with ';' seperator character.

For example:

java -cp jssc.jar;bin/anon/;libs/a.jar;libs/;.... anon.Main

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=356775&siteId=1