Couldn't find or load main class when running jar file

Viewed 589

I know this is a common issue, but i've tried many things to make this work.

Main Class name: Test

I've included a MANIFEST.MF with Main-Class attribute, as follows:

  1. Main-Class: src.client.Test
  2. Main-Class: classes.client.Test
  3. Main-Class: client.Test
  4. Main-Class: Test

None of the above worked.(the jar is located in the deploy dir )

This is the contents of my project: enter image description here

On my deployment profile i have included:

  1. MANIFEST.MF
  2. lib directory
  3. All the merged content of the file's group contributor (Test.class , an external jar that i'm using )

Note: I'm using JDeveloper 12c IDE


Related posts i've tried but i couldn't make it work:

Could not find or load main class with a Jar File

Cannot run jar file: Could not find or load main class Hello

2 Answers

You jar should have the following structure:

  yourjar.jar
  |-client
  | |-Test.class
  |-com
  | |-external
  |   |-package
  |     |-SomeClass.class
  |     |-SomeOtherClass.class
  | ....
  |-META-INF
    |-MANIFEST.MF

And your MANIFEST.MF file should contain

Main-Class: client.test

I mentioned correctly the Main-Class attribute, although the Class-Path was wrong.


The structure of the .jar file is the following:

myjar/client/Test.class

myjar/META-INF/MANIFEST.MF

myjar/myexternal.jar


I Had to mention myexternal.jar in my MANIFEST.MF as follows:

Correct: Class-Path: ../myexternal.jar

Wrong : Class-Path: myexternal.jar

I don't know if that is making any sense, i shouldn't get an exception loading the main class because of the wrong way of mentioning myexternal.jar

Nevertheless this fixed it!

Related