Certificate issue: mvn exec:java sees it, java -jar does not
===

I have installed a security certificate and I have a problem. When I run my code with 

    mvn exec:java -Dexec.mainClass="com.myproject.MyClass"

it works fine. But when I try to package things in a JAR, and run it with:

    java -jar MyProject.jar

I get a 

    Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
            at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
            at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
            at sun.security.validator.Validator.validate(Unknown Source)
            at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)
            at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)
            at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
            ... 32 more
    Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
            at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
            at java.security.cert.CertPathBuilder.build(Unknown Source)
            ... 38 more

I create the jar with

mvn clean install jar:jar

On the same level as the jar I have a directory called lib, and in lib I have all the dependencies. The dependencies were added to the MANIFEST.MF file in my jar, the path for them is correct, the lines are not too long (one dependency on each line).

Maven and Java use the same JDK. They should normally have the same dependencies on the classpath, too. But it seems that java -jar ignores the certificate.

Can someone explain why this happens ?

Thank you.