Hi guys!
I sincerely hope that someone can help me. I am trying to use property file and my code looks like
package test.alex;
import java.util.*;
import java.io.*;
public class Main {
public Main() {
try{
Properties prop = new Properties();
File f = new File(getClass().getResource("test.properties").toURI());
FileInputStream inS = new FileInputStream(f);
prop.load(inS);
System.out.println(prop.getProperty("user"));
}
catch(Exception exp){
exp.printStackTrace();
}
}
public static void main(
String[] args) {
Main m = new Main();
}
}
Property file is located in test.alex package. After compilation I have got test.jar with structure
META-INF/
META-INF/MANIFEST.MF
test/
test/alex/
test/alex/Main.class
test/alex/test.properties
and when I run jar like
java �cp test.jar test.alex.Main I am getting next Exception
java.lang.IllegalArgumentException: URI is not hierarchical
at Java.io.File.<init>(Unkonw source)
�
Whould you be kind to excplain me where i am doing wrong
Thanks in advance