We are building a JAVA Application that communicates data over secure HTTPS lines.


When we run our application from Eclipse/Terminal, via the command "java -jar <application>.jar", the application succeeds in all regards. However, when we run our application from "clicking" on the jar file, or when we run it from our bundled OSX Application files, we experience the following error:

sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

We have added all of the respective certificates to the keystore, and we have tested this extensively. I should also add that we have researched extensively this error, but it mostly resolved around certificate issues. As we can run the application successfully under certain scenarios, we don't believe this is the case.

My current hypothesis is that we need to sign our Java application and/or the OSX Application file generated from our ANT script.


Do any of you have any ideas on what is causing this error? Any ideas on how to fix it?

1 Answer 1


Literally right after typing this question up, my coworker found the solution.

Apparently, the "JAVA_HOME" variable changes based on the context of where you ran your jar. If you run the application directly, the variable leads to

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

Whereas running it from bash/terminal/eclipse causes it to be located elsewhere

What this means in the context of this problem, is that we were not adding our certificates in all of the places necessary. Should you come across this, please verify that you are adding your certs in the correct locations.

  • 1
    Wow, have been trying all methods i.e. importing self signed certificates into cacerts of JAVA_HOME. It gets imported successfully but the never never resolved. You are genius. After importing the same certificate using /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home as JAVA_HOME, the problem GONE. I am so delighted. Thank you very much. Sandip Jun 2, 2018 at 23:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .