• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bundle certificate file inside .jar file

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,


Using an API that requires certification file for initialization;
When certificate file is anywhere in the file system it can be loaded properly via it's path, but when i bundle it into plugin.jar
and tried to reach it via:

it gives
java.lang.InstantiationException: API Client initialisation failed: Could not open certificate file 'file:\C:\application_server\plugins\payway.jar!\certificate\certificatefile.q0' - check that the correct certificate file is being referenced
Formerly i used for other resources, config files and it worked properly


Is it possible to bundle certificate file into .jar file? How to do this correctly?



Regards
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One cannot use getFile() on a URL that is not a file URL. Are you sure that the API you are using does not have an alternate method/constructor that takes in InputStream rather a File? If there is such a method/constructor then you can use

to get an InputStream.

If there is no appropriate method/constructor then your only real choice is to copy the certificate out of the jar file and write it to a temporary file on disk. You can do this by copying the content of the InputStream obtained from getResourceAsStream() to a FileOutputStream.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic