Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :(
Posted

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


and so on.


Greetings
Painjofshem
 
Share this answer
 
Comments
Dalek Dave 7-Nov-11 3:45am    
Yep, true.
TorstenH. 7-Nov-11 3:46am    
If you want to use relative paths - yes. But that's pure logic - you can't use relative paths when you're not able to address your files correctly.

There are different folders and places you can also address without knowing where they reside - e.g. the temp-folder of the OS.
Sometimes it's simpler to pass a task to the OS - e.g. opening a PDF-file.

All other paths have to be absolute. In that case you need to know about the configuration of the system and must be sure that it does not change.
epanjohura 7-Nov-11 3:48am    
I know, thx
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.
 
Share this answer
 
v2
Comments
epanjohura 9-Sep-11 7:36am    
I have to give arguments if I want to run my application, that means, I have to give a path to my config.ini-file which is given as an absolute path.
But I wanted to use both the absolute and the relative paths.
TorstenH. 9-Sep-11 13:03pm    
that one should be relative, as you don't know where and how the application will be placed. No absolute path here.
epanjohura 12-Sep-11 1:51am    
No, this path is absolute.. I've tried it with a relative path and that didn't work.. :S
TorstenH. 13-Sep-11 12:50pm    
is it a Eclipse RCP application? http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html

Or some Java-Application developed under Eclipse IDE? Then you need to process that argument yourself.
epanjohura 19-Sep-11 3:39am    
It's a Java-Application developed under Eclipse IDE

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900