如何在Eclipse中使用相对路径而不是绝对路径?

问题描述:


我正在用Java编程,并且使用了abolute路径来包含其他文件.我的问题是,eclipse中是否有任何设置只能使用相对路径,还是必须通过一些代码行来实现?

希望有人能帮助我,我感到绝望:(

Hi
I''m programming something with java and I''m using abolute paths to include other files. My question is, are there any settings in eclipse to use only relative paths or do I have to realize this with some lines of code?

I hope someone can help me, I''m desperated :(

现在我知道我真的很蠢:S

所需文件必须与项目文件位于同一文件夹中:

Now I know I was really dumb :S

The needed file has to be in the same folder as the project p.e.:

current directory: C:\xy\xz\xx\.

absolute path of file: C:\xy\xz\xx\file.txt
relative path of file: .\file.txt

or
absolute path of file: C:\xy\xz\file.txt
relative path of file: .\..\file.txt



等等.


问候
Painjofshem



and so on.


Greetings
Painjofshem


其他文件,例如图片,图标,打印模板?

-在文件夹"src"旁边添加一个文件夹"resource"到您的项目中
-在下面建立一个体面的结构(打印",属性",图标")

在代码中使用相对路径引用这些文件夹:"/resource/icons/..."

构建应用程序时,您可能必须解压缩资源文件夹.
Other files like pictures, icons, print templates?

- add a folder "resource" to your project aside of the folder "src"
- underneath build up a decent structure ("print", "properties", "icons")

in the code refer to these folders with a relative path: "/resource/icons/..."

You might have to unpack the resource-folders when you build your application.