This discussion is archived
1 2 Previous Next 16 Replies Latest reply: Apr 18, 2009 1:18 PM by 843789 RSS

"Could ntot find the main class : PdfToImage"

843789 Newbie
Currently Being Moderated
I am trying to produce a jar that I can execute from the command line. Currently it executes fine if I hit F6 to run the code in the Netbeans IDE.
I read this article:
     http://java.sun.com/developer/Books/javaprogramming/JAR/basics/run.html
but still can't get it to run from the command line. The error I get when clicking on the jar file is:
"Could not find the main class PdfToImage"

The source code is this:

package converttoimage2;
...import statements here
public class PdfToImage{
     public static void main(String[] args) {

To build a jar file I navigated to the NetbeansProjects folder and typed the following (is this wrong?)
     jar cfm PdfToImage.jar ConvertToImage2\manifest.mf ConvertToImage2
No error messages occured here. The manifest file originally was this (BTW I don't understand what that X-comment is trying to say)
     Manifest-Version: 1.0
     X-COMMENT: Main-Class will be added automatically by build
so I added this line:
     Main-Class: PdfToImage
and yes, I pressed Enter at the end of this line. This is the manifest that generates the error. I get the same error this way:
     Main-Class: converttoimage2.PdfToImage
The code I'm using from the Windows command line to execute the jar (after I copy the jar file to the c-drive) is this:
     java -jar C:\PdfToImage.jar
This errors out with
     Could not find the main class: PdfToImage
I've also tried this;
     java C:\PdfToImage.jar

The next thing i tried was to navigate to the class folder containing the PdfToImage.class. I copied the manifest into this class folder as well.From there I typed:
     jar cfm PdfToImage.jar manifest.mf PdfToImage
This produced a jar file with no error messages, but I get the original error messsage when I try to execute. Also I doubt this last jar file is complete since it is only 2KB in size (My code references a library called PdfRenderer which is a 2MB jar).

I'm completely lost here.
1 2 Previous Next