Question:
what is the relative path of this file?
fdev
2012-06-04 08:22:27 UTC
I have a file and I need to know the relative path of this file. The directory structure is:
src -> a.b.c.currentFile
The file that I need the path for:
src -> dir1/file1.txt
a, b, c are packages. currentFile is the file where I need the path for the "file1.txt".
I need the relative path because the code should work on different machines. I am using Windows and Eclipse for development.
Three answers:
AMiT
2012-06-04 08:34:43 UTC
Relative path is the one which you consider from which directory you are currently in. i.e

if your file abc is the current file in the directory src than your relative path becomes



src/abc



Absolute path is always starting from the first point i.e from your disk drives



C;/program files/java/jdk



this becomes absolute path.



Cheers!!!
?
2012-06-04 08:32:05 UTC
I don't understand what you are saying because you aren't using standard notation, but you should be using getresource to obtain the full path of the file you want relative to where the application is currently running.



http://lj4newbies.blogspot.com/2008/03/using-classgetresource-load-resource.html



also see half way down this page.



http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html



This works on every OS and in a JAR file should you choose.
razny
2016-10-21 10:55:48 UTC
you should artwork with ecosystem variables. suitable click MyComputer and make positive the stepped ahead tab is chosen. use the button "ecosystem Variables". the following you may introduce an ecosystem variable and upload a value like ProgDir="c:myRootDirectory". make positive this listing is pointing to the listing you've your software or documents saved in. Your software then ought to make use of the following code: String strPath = equipment.ecosystem. GetEnvironmentVariable("ProgDir"); String strSubdir = strPath +"this technique textual content information" ; look into equipment.ecosystem.SetEnvironmentVariabl... strVar) besides. desire that enables Subcommander Avocado.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...