简体   繁体   中英

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

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: 在此处输入图像描述

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

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM