java - image not showing in JAR -


I have created an image that uses an image as the background of the image when I run it in the eclipse I work perfectly, but when I put it in a .jar file, the image is not displayed. I got the same posts and I tried the solutions but nothing worked.

What am I doing here

  Private Zero Init () {setPreferredSize (new dimension (W, H)); SetVisible (true); Url = getClass () GetResource ("Graph2.png"); System.out.println ("value =" + url); Img = Toolkit.getDefaultToolkit (). CreateImage (url); }  

The manufacturer asks this function to initialize the GUI, then I ask this function to draw the image in drawing.

  Zero Initial Grid (Graphics G) {Graphics 2DG2D = (Graphics 2D) G; G2d.drawImage (IMG, 0, 0, this); }  

Not sure what the problem is that I tried to put the image everywhere, inside a bin without a folder inside the bin, inside the GII package, nothing worked. Does

Thanks in advance

The usual way to set this up is to Make your folders in Eclipse: Resources in your code structure properly, like in

  bin / resources / src /  

Src and bin source in src .

Copy the image file to resources in the same code as the class trying to load. Add both src and resources as the path, source, source folders. Now when you create the project, the contents of resources will be copied to bin and it will work with your IDE as well as jars.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -