Results 1 to 3 of 3
Thread: Can't load images
- 07-30-2011, 04:57 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 5
- Rep Power
- 0
Can't load images
I've looked throughout the internet on ways to modify images, but my biggest problem is that I can't load images unless I specify the full path! I have the image in the same directory as the class & java files. I use eclipse, and it gives a qualified name, or I use just the base name like tutorials do, but I always get a null pointer exception.
Java Code:Image img; Toolkit tool = Toolkit.getDefaultToolkit(); img = tool.getImage("test.png");
Java Code:Exception in thread "Thread-4" java.lang.NullPointerException at com.ityguy32.AppletGame.ImageReader.<init>(ImageReader.java:18) at com.ityguy32.AppletGame.Start.run(Start.java:22) at java.lang.Thread.run(Unknown Source)
- 07-30-2011, 05:54 AM #2
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,236
- Rep Power
- 13
-
You need to know where Java is looking for the file, and likely it's the user's working directory. To find out what this is, place this somewhere in a program in the same package as your current program:
Java Code:System.getProperty("user.dir");
Similar Threads
-
How to Load images one by one...
By abhay_mishra in forum AWT / SwingReplies: 0Last Post: 05-09-2011, 06:23 PM -
Load and Save images
By shakeel in forum Java 2DReplies: 13Last Post: 12-29-2010, 07:38 PM -
how to scroll 2 images at a time(synchronisation),both images are on different panels
By smitharavi in forum AWT / SwingReplies: 4Last Post: 12-16-2010, 05:32 PM -
Load Images, XML Contents with Eclipse IDE & BEA Weblogic Support
By sherazam in forum Java SoftwareReplies: 0Last Post: 08-13-2010, 11:52 AM -
Cannot load images at the SliderDemo
By HelloRick in forum New To JavaReplies: 0Last Post: 10-07-2009, 10:58 AM
Bookmarks