相关文章推荐
坚强的面包  ·  React ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams Possible duplicate of Java, Classpath, Classloading => Multiple Versions of the same jar/project xtratic Nov 16, 2018 at 19:41 It is possible that library you use could depend on bcprov-jdk15 while another library depends on bcprov-jdk16 . But the issue is that Java can't easily distinguish between different versions of the same qualified names. Often you can use the higher version if that dependency (in this case Bouncy Castle) maintained backwards compatibility. See this link as well. xtratic Nov 16, 2018 at 19:52

The 15 and 16 point to JRE 1.5 and 1.6 for compatibility. Your version is 1.46 at most because that's the latest version where the JDK 1.5 and 1.6 were targeted separately. The 1.46 version was created on February 2011 . The current version is 1.60, July 2018.

So you do not need nor should want either of those jars. You probably want the latest, otherwise you may be behind with regard to security fixes. Note that you should do some testing to see if the latest version runs with your code and change your code if it doesn't. Generally Bouncy Castle libs are backwards compatible, but some components such as its own ASN.1 API have gone through some serious changes.

So you'd better use this one from the Maven repository or download the latest from the Bouncy Castle site itself . You should use the one with 15on, which is for all versions of Java equal or greater than 1.5 (on = onwards).

Storing these jars without their version number is of course ludicrous. If you need to rename .jar files just to make your code run then there are some issues that you need to address.

Yes you are correct I am using bcprov-jdk16-1.46 along with bcprov-jdk15on-1.60.If I have understood this correctly then removing bcprov-jdk16-1.46 this shoudnt be havin any impact as bcprov-jdk15on-1.60 will be having all the features . Rajeev Akotkar Nov 17, 2018 at 4:02 Yes, in almost all cases that shouldn't have any impact. I've actually seen cases where removing BC entirely didn't do any harm, but that's less likely. Please try to remove 1.46 and test the software! Maarten Bodewes - on strike Nov 17, 2018 at 4:07 And? Did it work? Please don't forget to upvote good answers and accept one of them. I see you have ever accepted a single answer, so it seems you know what to do. Accepted answers helps others and it is the best way of saying thanks on StackExchange. Maybe it is time to revisit some of the old questions? Maarten Bodewes - on strike Nov 27, 2018 at 6:55

The java version is relevant to Bouncy Castle. What you have are jars for Java 1.5 and Java 1.6
You should have only 1 in your classpath and use the Bouncy Castle jar closest to your Java runtime environment version. When you have more than one, you dont know which version of the code is being run. Class loading orders are not guaranteed and typically differs across environments, java versions, etc. You are more likely to have bugs that are difficult to reproduce when you have two versions of the same jar.

What is important is the last 3 digits in the version e.g. 149 in bcprov-jdk15on-149.jar . This is the actual version of Bouncy Castle. Pick whichever is the newer one.

You should analyze your classpath dependencies (e.g. mvn dependency:tree ) to understand which versions are you actually using. In principle the newer version should be backward compatible but this is not guranteed and there could be bugs .

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .