Мое маленькое приложение отлично работает на Eclipse, вместо этого возникают проблемы, когда я пытаюсь вызвать его jar из командной строки.Проблема выглядит как в моей папке ресурсов, куда я помещаю файл свойств.
java.io.FileNotFoundException: file:*****************************\EasyDeployment\target\EasyDeployment-0.0.1-SNAPSHOT.jar!\ssh.properties
(the syntax of the file name and the directory name or the value label it is not correct) // I translate this part that was in my native language
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at Configuration.PropertiesMenager.getAllKeys(PropertiesMenager.java:91)
at GraphicInterface.SshChooser.initialize(SshChooser.java:101)
at GraphicInterface.SshChooser.<init>(SshChooser.java:62)
at GraphicInterface.SshChooser$1.run(SshChooser.java:49)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
моя структура:
мойссылки:
public final static String SSH_PROPERTIES = "ssh.properties";
public final static String PORT_PROPERTIES = "port.properties" ;
public final static String CMD_PROPERTIES = "cmd.properties" ;
public final static String CONF_PROPERTIES = "configuration.properties";
пример метода, который вызывает эти свойства:
public String getPropertiyByKey(String key, String propFile) throws IOException {
Properties prop = new Properties();
FileInputStream objFileInputStream = null;
objClassLoader = getClass().getClassLoader();
String result = "";
try {
System.out.println(propFile);
objFileInputStream = new FileInputStream(objClassLoader.getResource(propFile).getFile());
prop.load(objFileInputStream);
result=prop.getProperty(key);
} catch (Exception e) {
e.printStackTrace();
} finally {
objFileInputStream.close();
}
return result;
}