|
Re: Eclipse always searches file in workspace - how to change? [message #1198280 is a reply to message #1198256] |
Wed, 20 November 2013 08:32 |
|
On 11/20/2013 01:18 AM, Heiko Schmittwer wrote:
> Hello!
>
> I am including a file in my project like this:
>
> File xsl = new File("stylesheet.xsl");
>
> The problem is that Eclipse always looks for that file in the workspace.
> But I want it to look for that file relative to where the class-files
> are. I am trying to make a runnable jar of my programme but the
> programme will always look for that file in the workspace. If I put the
> stylesheet in the same folder as the .class-files (i. e. the package) I
> want the programme to look for the file in that folder.
>
> How can I get that to work?
What you say isn't completely accurate. It's not Eclipse's fault per se.
In fact, this has little to do with Eclipse. It's the nature of Java
file I/O. Eclipse creates a microcosm in the project of what your
program will find when running out there in the big, bad world outside
of Eclipse.
But, Eclipse can help as recounted in a very recent post you missed when
you searched this forum:
"[Eclipse's] Java Application launcher allows you to set the working
directory on the Arguments tab."
Alternatively, you can play around creating files with different path
arguments in Java until you get a feel for how best to do this.
|
|
|
|
Powered by
FUDForum. Page generated in 0.09171 seconds