Trying to run jar file but getting cannot find class

I am trying to run a jar file from the Win7 command line, but am getting the dreaded could not find or load main class PRCreateExecution.

I can successfully build the jar file from a Win7 batch file on the command line.

My current manifest file is named PRCreateExecution.mf and is located in here: C:\WDEclipseIDEWorkspace\MC3\src\PurchaseRequests\

The manifest file contains:

Manifest-Version: 1.0
Created-By: 1.8.0_40 (Oracle Corporation)
Main-Class: PurchaseRequests.PRCreateExecution.class

(extra LF is here)

I run the Win7 batch file to build the jar from C:\WDEclipseIDEWorkspace\MC3\src\PurchaseRequests:

jar -cvmf PRCreateExecution.jar C:\WDEclipseIDEWorkspace\MC3\bin\PurchaseRequests\PRCreateExecution.mf C:\WDEclipseIDEWorkspace\MC3\bin\PurchaseRequests\PRCreateExecution.class C:\WDJarFiles

The jar file gets created successfully.

Now I'm using this batch statement to try and run the jar file:

java -cp C:\WDEclipseIDEWorkspace\MC3\bin\PurchaseRequests;. PurchaseRequests.PRCreateExecution

from in here:

C:\WDEclipseIDEWorkspace\MC3\src\PurchaseRequests

but am getting the could not find main class PurchaseRequests.PRCreateExecution.

PRCreateExecution source snippet:

package PurchaseRequests;
public class PRCreateExecution {
public static void main(String[] args)

Thanks for any help...

Jon Skeet
people
quotationmark

Firstly, it sounds like you're not actually trying to run your jar file at all. You're not mentioning it anywhere on your command line.

Secondly, it looks like your classpath is wrong - it should probably be

java -cp C:\WDEclipseIDEWorkspace\MC3\bin;. PurchaseRequests.PRCreateExecution

That's assuming that the bin directory contains a PurchaseRequests directory which contains PRCreateExecution.class

Thirdly, you should follow Java naming conventions for packages - they should be lower case.

people

See more on this question at Stackoverflow