• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Cannot get icons to work when I export runnable jar from Eclipse.

 
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The jar runs perfectly but it doesn't have my icon and logo.
The image is in a resourse folder and it is included in the build path.
The image is also in the jar file. I don't know how to solve this.


I am using JavaSE12

Any help is greatly appreciated.


 
Rancher
Posts: 144
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May try this:

The important part is the leading "/" at the beginning of the file name.
 
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The image may be in the jar file but is it in the right place in the jar file?

The URL you have there for the image (yes, that's a URL) is relative to the class in which that code is located. For example if the full name of that class is "name.gilbert.ray.Thing" then you'll want to have the image file in the /name/gilbert/ray/resources folder in the jar.

But chances are you want to have the image in the /resources folder, and most likely that's where it got put when you built the jar. If that's how you want to set up your jar (and it's a very reasonable thing to want) then you need to use an absolute URL:

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse isn't putting the resources folder in the jar just the image.
I tried opening the archive, adding a folder and putting the image in it but it still does not work.
Placing the '/' before resources "/resources/OmniAsym200.gif" only makes the image not show
when I run it in Eclipse. It seems like it should be an easy thing to do.

In the jar is a META-INF folder, an org folder, the resources folder that I created after I exported the jar.
then there are the JCalendar class files.

This is the Manifest:


I have read some on manifest files but I still don't have
a clear idea how to work with them and eclipse outputs
a different manifest than what I saw on Oracle's site.
 
Marshal
Posts: 4014
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you building your jar?

Have you configured the resources folder as a project source?
 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ron McLeod wrote:How are you building your jar?

Have you configured the resources folder as a project source?


I am exporting a runnable jar with Eclipse IDE.

Configured as a project? I have the resources folder in the source tab of
the build path.

"Source folders on build path:

>JCalendar/resources

>JCalendar/src"
 
Ron McLeod
Marshal
Posts: 4014
549
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kristina Hansen wrote:May try this:

The important part is the leading "/" at the beginning of the file name.


I think that you will find that if you use getClassLoader(), then the leading slash is not used.  Here's a simple example:




Source file structure:

Eclipse project build path configuration:




Contents of built jar:

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried it.

Still has default java icons:

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I poked around and tried it this way and it works!

Though no one this far had the exact solution yous guys
helped me look around in the right areas to fix it.

Thank you all for your responses, help, and input.
 
Kristina Hansen
Rancher
Posts: 144
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be helpful for others reading this later on how you fixed it in the end.
 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kristina Hansen wrote:It would be helpful for others reading this later on how you fixed it in the end.



Yes, sorry. I meant to post the code but I forgot.

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I have images!

 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*UPDATE*

It only worked on that one app. I have another and it fails. It won't compile.

Back to the drawing board.
 
Kristina Hansen
Rancher
Posts: 144
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ray Gilbert wrote:

Kristina Hansen wrote:It would be helpful for others reading this later on how you fixed it in the end.



Yes, sorry. I meant to post the code but I forgot.


Well, then your image isn't located in the place it should be. Check your build config to see how your IDE packs the JAR.
 
Rancher
Posts: 4893
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

It won't compile.


Please copy the full text of the error message and paste it here. It has important info about the error.
 
Ray Gilbert
Ranch Hand
Posts: 126
1
MyEclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here it is:

 
Norm Radder
Rancher
Posts: 4893
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Make sure the image file is being found so that the value of url is not null.
 
And inside of my fortune cookie was this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic