Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Can't display an image...

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can't display an image...

    this is a simple program i wrote; i have to use this Picture.class file that my professor provided, and thus i am having a lot of trouble undertand how to use the file with the program. eventually i will have to manipulate the image itself, but right now i can't even display it.

    i am getting one error when i try to compile, read as: java/image/Picture.java:1: <identifier> expected


    import Picture.class;

    public class Picture
    {
    public static void main(String[] args){
    Picture pic = new Picture("caterpillar.jpeg");
    pic.showImage();
    }
    }


    any ideas?


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Can't display an image...

    You never import files with .class extensions.

    if you have a Picture class in the package media, you would import media.Picture;
    Do not name your class the same as ones you expect to find in the libraries provided by your professor, as it is bad practice and confusing.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can't display an image...

    i have three files in one folder: one is the Picture.java file, one is the Picture.class file, and the other is the image i am trying to display.

    if i use import media.Picture; then i get three errors. if i use import Picture; then i get two errors that read:

    image/Picture.java:1: '.' expected
    image/Picture.java:1: ';' expected

    what am i doing wrong now?

  4. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Can't display an image...

    Haven't got a clue what you're on about sorry.
    How new are you to Java? because it would be to everyone's benefit if you went over the tutorials first.

    Post the code you have when you receive those errors.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

Similar Threads

  1. Create image Jpeg from an object of Image class.
    By Ramandeep in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: December 31st, 2011, 11:34 PM
  2. Trouble getting an image to display.
    By Skyhigh32 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 23rd, 2011, 07:52 AM
  3. Display Image (png)
    By vimalaranjan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2011, 06:44 PM
  4. How to display a button with an image on it?
    By ice in forum AWT / Java Swing
    Replies: 10
    Last Post: November 13th, 2010, 06:20 AM
  5. Using JFileChooser to open and display an image
    By JavaN0ob in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 31st, 2010, 06:01 PM