0

If I import a .jar into a Java project(Eclipse) in which there is a function using an IO and a File with a given path/name to load that file, and I call that function within a class in my project, where does the file have to be? Would it have to be in the .jar? In the project folder? The same folder as the .jar?

2
  • Put files on places where u mention and check what will be output like error/work? Commented Jan 20, 2015 at 3:08
  • It depends on the path that java code inside the jar uses. If there is specific path and just the filename, then the file should be present on classpath Commented Jan 20, 2015 at 3:12

1 Answer 1

0

File represents a file in the filesystem.

If you don't use absolute paths, the path will be relative to the working directory of your application.

By default, the working directory of a Java application started as part of a Java project from Eclipse will be the root folder of that Java project. You can change it in the "Run" dialog options.

If you don't want to load from the filesystem, but from a resource contained within the Java project itself (so that it can be included in the jar file), you should not use File, but the classloader.

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.