Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/''javax.imageio.iioexception: can't read input file!'' - How to fix?
Next
Answered
ozellahammes
  • 3
ozellahammes
Asked: July 22, 20222022-07-22T04:08:31+00:00 2022-07-22T04:08:31+00:00In: java

”javax.imageio.iioexception: can’t read input file!” – How to fix?

  • 3

. Advertisement .

..3..

. Advertisement .

..4..

I’m a new in Java. I encounter the ”javax.imageio.iioexception: can’t read input file!” error when I want to insert an image into my window.

package graphics;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
import src.Common;

public class Window extends JFrame
{
public class Panel extends JPanel
{

    public void paintComponent(Graphics g)
    {
         Image img;
         try
         {
         img = ImageIO.read(new File("/logo.jpg"));
         g.drawImage(img, 0, 0, this);
         }
         catch (IOException e)
         {
         e.printStackTrace();
    }

}
}

public Window(String title, int width, int height)
{
    this.setTitle(title);
    this.setSize(width, height);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setContentPane(new Panel());
    this.setVisible(true);
}

I tried putting the image I wanted to read in each folder, but the problem still occurs.

what went wrong with me?

  • 1 1 Answer
  • 170 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    hdtutoria Expert
    2022-07-22T04:12:00+00:00Added an answer on July 22, 2022 at 4:12 am

    The cause: The issue is that nothing is shown before the image, so your computer is searching for it in a folder that doesn’t exist.

    Solution: You must first create the folder to store the images in your project and then place the folder name in front of the image name.

    e.g.

    ImageIO.read(new File("Folder/Image.png"));

     

    • 2
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.