0

For my Java application, I use some input files inside src folder. But after I create the jar file and use it, it gives an error saying cannot find the file. How to add an input file when creating jar file in NetBeans?

1 Answer 1

1

You need to use getResourceAsStream(String name), to get a stream to the file:

InputStream is = MyClass.class.getResourceAsStream("fileName"); 

This will return an input stream to the file fileName which is located inside a directory that MyClass.class is in.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.