0

I am having difficulties saving pictures that I have loaded. The picture is saved under the same folder where this program is. An error keeps reappearing. The error screen is below

Error

---------- Capture Output ----------
>"C:\Program Files\Java\jdk1.6.0_22\bin\java.exe" loadapicture
java.lang.NoClassDefFoundError: loadapicture
Caused by: java.lang.ClassNotFoundException: loadapicture
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: loadapicture.  Program will exit.
Exception in thread "main" 
> Terminated with exit code 1.

My program

import hsa.*;
import java.awt.*;
// Look at all of these extra imports needed for a picture file
import java.io.File;
import java.io.IOException;
import java.awt.image.*;
import javax.imageio.*;


public class loadapicture{
    public static void main(String[] args){
        Console con = new Console();

        // Variables need to open a picture file
        File tictactoefile;
        BufferedImage tictactoeimage;
        tictactoefile = null;
        tictactoeimage = null;

        // Now that the variables are created.. Time to load the picture into the variables
        // BTW  You need to load the file using a block called try/catch
        // Becuase if the file does not exist, you need to catch the error
        // You can use jpg, gif, and bmp

        try{
            // Trying to open the file and loading it
            tictactoefile = new File("");
            tictactoeimage = ImageIO.read( owin.jpeg);

        }catch(IOException e){
            // If the file is not found, this will happen
            con.println("ERROR... IMAGE FILE NOT FOUND"); 
        }


        con.drawImage(tictactoeimage, 100, 100, null);

        // Yes you can do all of this in a method
}
}

How to download & save image correctly?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Chris Kevorkian
  • 157
  • 1
  • 1
  • 3
  • 2
    This does not answer your question, but "loadapicture" is a really bad name for a class. It is more the name for a method. A class should start with a capital letter. Consider: PictureLoader – W. Goeman Apr 24 '12 at 14:52

1 Answers1

2

I guess you just need to specify path to your class

"C:\Program Files\Java\jdk1.6.0_22\bin\java.exe" -classpath <path to your class> loadapicture
Anton
  • 1,432
  • 13
  • 17