aspose file tools*
The moose likes Game Development and the fly likes Where do I place my Image folder Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Where do I place my Image folder" Watch "Where do I place my Image folder" New topic
Author

Where do I place my Image folder

Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
Hi guys, I'm following a tutorial for creating java games, my compiler doesn't run the program Textures.java. From the compiler, it complains that: C:\Test>java com/zetcode/Textures
Jul 15, 2013 3:35:45 PM com.zetcode.Surface loadImages
SEVERE: null
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at com.zetcode.Surface.loadImages(Textures.java:35)
at com.zetcode.Surface.<init>(Textures.java:28)
at com.zetcode.Textures.initUI(Textures.java:83)
at com.zetcode.Textures.<init>(Textures.java:76)
at com.zetcode.Textures$1.run(Textures.java:97)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

hereException in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.awt.TexturePaint.<init>(Unknown Source)
at com.zetcode.Surface.doDrawing(Textures.java:50)
at com.zetcode.Surface.paintComponent(Textures.java:68)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JLayeredPane.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
at java.awt.Container.paint(Unknown Source)
at java.awt.Window.paint(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at javax.swing.RepaintManager$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$1000(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source).
I think I placed the image folder in the wrong package. Though, the program compiles. Kindly help! Thank you in advance.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2359
    
    7

Well I'm not into game development just yet but what's your loadImage() method look like?

Is your image folder outside or inside your application jar?


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
This is the loadImage() method:


I really don't understand how to create a jar file yet. As you can see, i included an error print to indicate if the exception was actually caught from this try block.
Thank you for helping. Waiting to here from you soon.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2359
    
    7

Try putting your images in the com.zetcode package.
Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
It's still not working. As a matter of fact, I have the image folder in every folder. From the com to the zetcode and even where the com directory is. Can someone plllleeeeaaase HELP ME OUT!
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2359
    
    7

Shamsudeen Akanbi wrote:It's still not working. As a matter of fact, I have the image folder in every folder. From the com to the zetcode and even where the com directory is. Can someone plllleeeeaaase HELP ME OUT!


Don't put the image files in a "image" folder. Put them next to the java source. So your com/zetcode folder should have java and png files.
Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
I sincerely appreciate all your advices.... Seriously, but it's still not working. However, i'll just post the whole code. I think i've tried all I can. Kindly run it and use test picture cases with the names: slate,java,pane. All .png files.

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2359
    
    7

OK the images goes in the working directory. Say you are in C:\test

You put the png in C:\test. Put the java source in C:\test\com\zetcode

Then in C:\test you compile and run

> javac com/zetcode/Textures.java
> java com.zetcode.Textures

Voila.
Shamsudeen Akanbi
Ranch Hand

Joined: Dec 24, 2010
Posts: 71
Wow! Thank you, it works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Where do I place my Image folder