I can't access my images!!!

Greetings

First I thought it might be an error in my code but upon executing the following code that calculates the images's height and width it returns -1 values? the test.jpg exists in the same folder as the ImageXY.java file and it's size is 100 * 100, I tried creating many other images, but the same problem persists. i'm using IDE3.6 with jdk1.4.2_05, although i coded it using dos prompt too.

[code:]

import java.awt.*;

import javax.swing.*;

public class ImageXY

{

public static void main(String[] args)

{

Image image = Toolkit.getDefaultToolkit().getImage("test.jpg");

ImageIcon icon = new ImageIcon(image);

int height = icon.getIconHeight();

int width = icon.getIconWidth();

System.out.println("height"+height);

System.out.println("width"+width);

}

}

[/code]

It's a really strange problem, I know there's something wrong with my java , can any body help?

[991 byte] By [Java_scientist] at [2007-9-30 22:09:04]
# 1
Probably just can't find the file, try an absolute path.
ChuckBing at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...
# 2
what is the absolute path?thanks in advance
Java_scientist at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...
# 3
One that starts at a drive letter (Windows) or root (Linux-UNIX). Windows, for example: C:\\directory\\test.jpg
ChuckBing at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...
# 4

thank you ChuckBing for your fast reply. i'll try it soon

I was trying to compile several java applications and it appeared that the problem is with NetBeans, compiling any file with NetBeans returns no errors, but executing don't display the image.

while compiling and executing in the dos window returns fine results!?

moreover, it doesn't matter if the images exist in the same folder in a different folder like in packages, all the tests that I did proved that the problem is with IDE. Does it have a different method to deal with images?

I'm starting to hate this IDE,

Java_scientist at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...
# 5
Well it worked!!!!!Thank you a lot ChuckBing, but why is this difference between IDE and normal Dos Windows?
Java_scientist at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...
# 6
I guess it''s because IDE usually has its own configuration for some environmental variables.
jobseeker at 2007-7-7 11:22:14 > top of Java-index,Administration Tools,Sun Connection...