I have a java class that uses the file "keystore\test.keystore" in a web application. This keystore file is used to encrypt and decrypt the credit card on my web site. But when the method to encrypt the credit is
getting called I am getting the following error.
[STDOUT] java.io.FileNotFoundException: keystore\test.keystore (The system cannot find the path specified)
I guess the file has to be on the server and its not finding it where it supposed to be.
Where should I copy this file on to the server? I am currently testing this in my localhost and I use a jboss server.
Most likely, the error is due to a statement of the form
java.io.File f = new File(directory,filename);
How did you set the directory? It's probably not pointed to the right place.
From the error text you show, it looks like you said that the directory is "keystore". That might work, depending on what the root is relative from which File() interprets your given directory. Better would be for the directory to be a complete path, starting at the system's root directory.
With web applications you should always use the ServletContext.getRealPath method to turn paths relative to the web application root to absolute paths.
I wouldn't put the keystore folder in your classes folder; make it a direct sub folder of the WEB-INF folder. That would make the parameter to getRealPath "WEB-INF/keystore/test.keystore". Because it's in WEB-INF it cannot be found by trying to access it directly; only your web application itself has access to it.