我想打开密钥库时遇到此异常
java.io.FileNotFoundException: \resources\keystore (The system cannot find the path specified)
基本上我的应用程序就像
src/
client.java
server.java
resources/
keystore
truststore
和错误的代码:
System.setProperty("javax.net.ssl.keyStore","/resources/keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "redacted");
我也尝试过./resources/keystore,资源/ keystore,\\ resources \\ keystore等。
我的应用程序应该在可执行jar中工作,所以请不要使用绝对路径技术。
最佳答案
您可以使用它来获取当前目录路径:
Java代码:String currentDir = new File(".").getAbsolutePath();
或这个:
Java代码:String currentDir = System.getProperty("user.dir");
关于java - java.io.FileNotFoundException(系统找不到指定的路径),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13742122/