This is harder than it looks!!

Started by darkprophet, November 17, 2003, 21:37:24

Previous topic - Next topic

darkprophet

so ive got this working right on the absolute path, how would I go about making a relative path, cause "./data/nehe.png" doesn't work, neither does "data/nehe.png"??  :?:

CaptainJester

Find out where your class file is ending up.  I don't know how NetBeans works.  Does it place the class file in the same directory as the source?  Does it put it in it's own directory, ie classes/NeHexx or bin/NeHexx.  Are you using the package declaration or is it in the default package?  Here is a scenario:

NeHe06.java is in package NeHe06 so it will be in directory - c:\Java\src\NeHe06.  When you compile, the class file is in c:\Java\classes\NeHe06.  In this case, the texture needs to be in c:\Java\classes\data.  Then the absolute path works.  Even if you are using the default package or a package that is 6 deep, the texture would still be in the same spot.
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities.  We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)
8)

Javapunk

What I did is find my current path.
File f = new File("");
System.out.println(f.getAbsolutePath());
Figure out were the image is in relation to the above.
I think I ended up using loadImage("bin/data/nehe.png")
ude!!!

darkprophet

hey guys/dolls/gents/ladies, i just got eclipse, and I switched over..and to be honest, I am v. impressed...VERY!

so how would I go about doing a relative path in eclipse if I am not using any package names?

CaptainJester

Put the data directory directly in the same directory as your java source file.  This is also where the class file will end up by default.
The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities.  We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)
8)

darkprophet

thx alot dudes, much appreciated.