Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Java in General and the fly likes eclipse import image / jar import image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "eclipse import image / jar import image" Watch "eclipse import image / jar import image" New topic

eclipse import image / jar import image

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

I have a program that has image icons. When I run my program from eclipse I must use

however When my program is run from a jar I must change the code like this

This is inconveinent. is there an alternative

[ July 24, 2006: Message edited by: Nikos Katsikanis ]
[ July 24, 2006: Message edited by: Nikos Katsikanis ]

Jesus lives
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16535

That's not an Eclipse issue or even an IDE issue. That's a general Java question.

BTW, Java accepts forward-slash file separators as acceptable substitutes for OS-dependent file separators in most cases. So you don't need to go to that much work. A statement like:

File myPic = new File ("C:/rootdir/mydir/imagefile.jpg")

Works just as well as

File myPic = new File ("C:\\rootdir\\mydir\\imagefile.jpg")

AND, since the forward slash isn't an escape character, you're less likely to mistype it!

It also understands mixing the two.

Customer surveys are for companies who didn't pay proper attention to begin with.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 31634

Moving to Java In General since this isn't specific to IDEs.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link:
subject: eclipse import image / jar import image