I have written the java class file which reads text file from same class path, parse it and write in output file. If I run this code from eclipse, it will works fine as expected.
This is the code I written to find input file.
URL url = ClassLoader.getSystemResource(“Filename.txt”);
But when I make it as a runnable jar, it throws “URI is not hierarchical – Java classpath error” exception.
Instead of that, just replace this code to solve this exception
File inputFile = new File(Thread.currentThread().getContextClassLoader().getResource(“Filename.txt”).getFile());
InputStream is = getClass().getResourceAsStream(“Filename.txt”);
Scanner cns = new Scanner(is);
Eclipses automatically find the current class loader path.