Runnable JAR from Eclipse does not run. Generates errors "could not find main".

Posted by Richard VanMetter on
URL: http://imagej.273.s1.nabble.com/Runnable-JAR-from-Eclipse-does-not-run-Generates-errors-could-not-find-main-tp5011155.html

I have created a ImageJ-plugin project in Eclipse with an appropriate
"launch configuration". The project includes the ij.jar as a "referenced
library". The launch configuration runs perfectly in the Eclipse
environment, but when I try to export a runnable-JAR file I get the
following error:
  "Could not find main method from given launch configuration."
and indeed the project will not run in Java (here is an attempt at the
command prompt):
             C:\Users\Richard VanMetter\Desktop>java -jar MFPPD52a.jar
             no main manifest attribute, in MFPPD52a.jar

Here is the manifest when ij is included as a folder in the JAR file:
             Manifest-Version: 1.0
             Class-Path: .
which has no reference to main method.

Here is the manifest when ij is included as a jar in the project JAR file:
             Manifest-Version: 1.0
             Rsrc-Class-Path: ./ ij.jar
             Class-Path: .

In both cases, I tried adding the following line to the manifest manually
             Main-Class: ij.ImageJ
The contents of the JAR file include, the classes written for my project
plus the following:
             ij (either as a jar file or unzipped as a folder, depending
on export libraries option)
             META-INF folder
             org folder

but, it still will not run either by double-clicking, or in a command
window via either of these commands:
             C:\Users\Richard VanMetter\Desktop>java -jar MFPPD52a.jar
             Error: Could not find or load main class ij.ImageJ

             C:\Users\Richard VanMetter\Desktop>javaw -jar MFPPD52a.jar
ij.ImageJ
             (no error message, but no run either)

For completeness, the following works fine:
             C:\Program Files (x86)\ImageJ>javaw -jar ij.jar ij.ImageJ


Has anyone experienced this problem? and know a solution?

Thanks to all,

Rich VanMetter

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html