Good vs. Evil

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
72 I have muscle pain from yesterday and need to bike for about an hour to get to my work....

today will be fun.........not.......
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
71 Gah! Would by chance anyone here know how to make user independent external jar paths in eclipse?
 

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
72
71 Gah! Would by chance anyone here know how to make user independent external jar paths in eclipse?
You mean so you can read to and write from files, if the jar/class file isn't on your hard drive in precisely the location where Eclipse puts it?

Just use relative file paths. If you want to open a file called stuff.txt in the same directory as the jar or class file, wherever that may be, simply do new File("stuff.txt"). If you want to go into a directory inside the one where the jar is located, do new File("whateverDirectory/stuff.txt"). In addition, every directory has two special directories inside it, named . ('dot') and .. ('dot dot'). Dot is the current directory (in case you need to do something with the current directory, for whatever reason), and dot dot is the parent directory. So, if your installer puts the jar file in a directory called bin, and puts config files in a folder next to bin called config, you can get to config files with new File("../config/stuff.cfg").

This isn't limited to Java, by the way. You should always use relative file paths in all code everywhere, unless you want to access something in a completely different part of the file system (e.g. /bin/bash or /dev/null, or C:\\Program Files for you Windows newbs). If "/usr/duckfan/documents/code/java/some_project/config/derp.txt" shows up in your code, you're doing it wrong.
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
71
This adding external libraries to the project, that are located in another location. The file is in the same place under everyone's user/username/ directory, but adding an external library will add relative to root, rather than relative to user.home

The file isn't in the same directory at all as the project, and the project isn't always in the same location to allow a relative path off of it to even work, if it was even possible. There isn't any path in the code itself.
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
69
Where? I know github was down, was that a ddos?
edit: Oh, dyn got attacked. Ick. TURN OFF uPNP!
 
Last edited:

Someone Else 37

Forum Addict
Feb 10, 2013
1,876
1,440
168
71
This adding external libraries to the project, that are located in another location. The file is in the same place under everyone's user/username/ directory, but adding an external library will add relative to root, rather than relative to user.home

The file isn't in the same directory at all as the project, and the project isn't always in the same location to allow a relative path off of it to even work, if it was even possible. There isn't any path in the code itself.
Well, in Unix, the user's home directory is called ~ (tilde), which won't help you much on Windows.

Maybe whatever language you're using has a getHomeDirectory() sort of function?
 

duckfan77

Popular Member
Mar 18, 2013
80
683
118
70 There is, but this isn't in the actual java code. This is going in another file of a language I don't know, and won't take a relative classpath. I'm trying to add an external file to the project without placing the file within the project.