• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem loading images

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm fooling around with jogl and I'm having trouble loading images to use as textures
my application is in a package named toys
the main app contains a JTabPane which has several tabs that do different stuff
each tab contains a JPanel, the individual panels are in a package called (surprise) panels
the image I want to load is in a package called (surprise) images
so it looks something like this



so, in my IDE (netbeans) I can load the image with this code



this says I have to go up a directory from where the panel is, then go into the images dir, it works fine in netbeans
it doesn't work once it's made into a jar file and I try to run it from the command line
any good pointers to trying to understand the whole path deal when it comes to stuff like this?
I'm kinda confused at the moment

TIA
Dave
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
perhaps the slashes need to be back-slashes

//getClass().getResource("../images/normal_earth_2400.jpg")
getClass().getResource("..\\images\\normal_earth_2400.jpg")
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
nope
changing to backslashes it still works in the IDE but not from the command line
continuing to investigate, ideas welcome

Dave
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmm, that's annoying
if I change my code to this



and dump the jpg into the directory with my panels it works both in the IDE and from the command line
apparently some sort of path issue
unfortunately, I want my images in their own folder

Dave
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us the exact directory structure of the project? Something tells me that the IDE is not using a bin folder or something similar, and the command line JVM is, or vice versa.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here's a pic of the directory structure

http://www.drobbins.net/pics/toys.jpg

Dave
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And are the resources and images also located in the folder with the class files?
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the file I'm trying to open is normal_earth_2400.jpg
in the picture you can see I have it in the directory with my various panels
the code I use to open it is



that works properly both in the IDE and running the jar file from the command line
what I'd like to do is have that jpg in the images directory, I don't want graphics file mixed with my source code, I've been down that road, trust me, "madness lurks there" :roll:

interestingly, I just made an images directory under the resources dir which is under panels
I place the jpg there and I can open it with



I can live with that but I don't understand why the first way didn't work
it doesn't seem to want to let me use .. to go up a directory
Ideas welcome but I can live with what I have

Dave
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic