Home > Back-end >  After solving the Java file package picture error problem
After solving the Java file package picture error problem

Time:10-13

Good bosses, complete Java a little game, today in the eclipse run is good, but after the JAR file method is used to derive the, can't run,

I learned that is image path problem, should be a relative path, the final changes are as follows:
Image1=ImageIO. Read (enclosing getClass (). The getResource ("/image/1. Dinosaurs PNG "));
Image2=ImageIO. Read (enclosing getClass (). The getResource ("/image/2. Dinosaurs PNG "));
Image3=ImageIO. Read (enclosing getClass (). The getResource ("/image/dinosaurs 3. PNG "));

But after the JAR file mode is used to derive the error in the CMD is as follows:
D: \ & gt; Java jar - D: \ Java \ Di jar
The Exception in the thread "main" Java. Lang. IllegalArgumentException: input==null!
The at javax.mail. Imageio. Imageio. Read (imageio. Java: 1388)
The at bag. Dinosaur. & lt; init> (Dinosaur. Java: 28)
The at bag. GamePane. & lt; init> (GamePane. Java: 37)
The at bag. The MainFrame. & lt; init> (MainFrame. Java: 12)
The at bag. The MainFrame. The main (20) MainFrame. Java:

My picture is in the SRC/image inside, inside the SRC/bag is my class about
Ask bosses to tell me, thank you

CodePudding user response:

Run under the jar file's path

CodePudding user response:

reference 1st floor tianfang response:
run under the path of the jar file is

Sorry, I put the jar file in D: \ in JAVA, or an error
D: \ JAVA> Java - jar Di. Jar
The Exception in the thread "main" Java. Lang. IllegalArgumentException: input==null!
The at javax.mail. Imageio. Imageio. Read (imageio. Java: 1388)
The at bag. Dinosaur. & lt; init> (Dinosaur. Java: 28)
The at bag. GamePane. & lt; init> (GamePane. Java: 37)
The at bag. The MainFrame. & lt; init> (MainFrame. Java: 12)
The at bag. The MainFrame. The main (20) MainFrame. Java:

CodePudding user response:

Images should be placed in a resource file directory, is the resource, especially the maven project,
Cannot guarantee that package can contain image files under the SRC, you look at the jar package, image file is in zip format, zip software can open
You print the image path and see if the correct

CodePudding user response:

reference tianfang reply: 3/f
images should be placed in a resource file directory, is the resource, especially the maven project,
Cannot guarantee that package can contain image files under the SRC, you look at the jar package, image file is in zip format, zip software can open
You print the image path and see if it's all right

I switch to the Runnable RAJ file, and modify the jar open the way for the javaw. Exe, also added in the registry "- the jar," but the jar double-click or can't open, so I can only be opened in the control line, or an error,

CodePudding user response:

After I extract the jar, found it really don't have pictures, but I don't know what to get, I searched on the Internet, says it is in the process of packaging image folder may disappear, I tried put the pictures and the class together, but still no pictures, can help me with please

CodePudding user response:

reference jianghai send the rest of my life * 5 floor response:
after I unpack the jar, found it really don't have pictures, but don't know how to get, I searched on the Internet, may say is in the process of packaging image folder disappeared, I tried put the pictures and the class together, but still no pictures, could you tell me you can help me with

It is only a source folder will be packaged

CodePudding user response:

Are you a maven project? How to generate the jar file?

CodePudding user response:

I resolved, I don't know why pictures did not appear in the navigator, as long as the pictures inside can successfully opened
  • Related