To solve the problem is not the picture after the Eclipse Export JAR file

I have an Eclipse export Runnable JAR file, double-click to run the program, which the pictures are gone.

Search the Internet for a long time, given methods are particularly complex, is to modify the code referenced in the original picture, the picture does not write directly to the location, but to use getResource () method.

However, there is a message given me inspiration: the picture does not show the reason for this is the wrong path to the jar package, or the picture is not packaged into a jar package.

Here's how I solved the problem.

(1) I unpacked it was found that the picture is not, the solution is Eclipse, right-click the project and select Build Path> Configure Build Path, as shown below.

  

  The following screen appears, click Add Folder, File check your picture folder where my project, I will be all the pictures stored in a folder of images.

  

(2) after pressing the above-described operation is completed, the JAR file again. Select Runnable JAR file, confirm and then select Package required ..., the following two graphs.

  

  

(3) decompression generated Jar file, you will find all the pictures directly in the folder, not in subfolders, that is to say before the images folder is already gone, so you only need all of the pictures in Eclipse path "images /" to delete just fine, if you have more than one place needs to be modified, you just need to find the "images /" and then replace the empty place, click replace All. This approach can result in you not run properly under the Eclipse project, but re-generated JAR packages can be run properly, before the modification if you want to restore only need to step revoked just fine (JAR package recommendations generated after revocation, Eclipse can ensure normal operation of the program, because you can not quit before entering the revocation, but also more difficult to replace by looking to recover).

(4) step by step to regenerate the JAR file 2. It's done.

Guess you like

Origin www.cnblogs.com/zhenqichai/p/fix-eclipse-exported-runnable-jar-not-showing-images.html