Relative Paths in Java, omg

Ok I just figured out that, what seemed to be a relative path is in reality the relative path of the starting program.
For instance:

We suppose, I got a directory: “D:/Java/Project”
in this dirrectory, there are .class files, .java files and folders which holds data like music and graphics.
normaly in all my classes the path goes like this:
for example the audio class : load every audio file from “audio/” + specific audio file name
until now everything like that worked, but only because I started the Project from within this very directory.

Assuming I got in “D:\Java” a batch file, that starts my project, like this: “java -cp ./Project MyClass”
if I run it, my code suddenly looks at “D:/Java/audio” for audio files instead of “D:/Java/Project/audio”

which means the relative path is in reality the relative path of the starting program and not from the class itself.

So how could I possibly get a relative path, telling my program, my audio class for instance again “stay where this class file is, then go to audio/ and there you got your audio files”, regardless at where I start my project ?

Applications normally use the registry for that (or something comparable)

Take a look at the Preferences class. (google a bit)

Just load your resources from the classpath.

load every audio file from “audio/” + specific audio file name

Use “/audio/” instead. That makes it relative to all roots (directories and jars) in the cp.