Results 1 to 15 of 15
  1. #1
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Class Wasn't Found in Project

    Here is my code:

    Java Code:
    /*
     *  <applet code="ImageViewer" width=200 height=200>
     *  <param name="img" value="Snow.jpg">
     *  </applet>
     */
    import java.awt.*;
    import java.applet.*;
    
    public class ImageViewer extends Applet
    {
     Image img;
     
     public void init() {
         img = getImage(getDocumentBase(), getParameter("img"));
     }
     
     public void paint(Graphics g) {
         g.drawImage(img, 0, 0, this);
     }
    }
    Any ideas?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: <No main class found>

    I've moved this to the Applets forum, as it appears you're trying to run an applet.

    How are you trying to run it? What's the actual error message you receive?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: <No main class found>

    I'm basically trying to display an image. I'm using a code from a Java book. I'm using Netbeanz.

    I run the code and I get

    Image Viewer class wasn't found in ImageViewer project

    Select the main class:
    <No main classes found>

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: <No main class found>

    Does it actually say Image Viewer, with a space?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: <No main class found>

    No, sorry

    It says: ImageViewer class wasn't found in ImageViewer project

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: <No main class found>

    Then I suppose this is actually a netbeans question, so I'll move the thread again. I suggest googling something like "netbeans class wasn't found in project". Better yet, ditch your IDE altogether and just compile by the command prompt until you're more familiar with the basics.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: Class Wasn't Found in Project

    I'm not too familiar with using the command.

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Class Wasn't Found in Project

    Quote Originally Posted by BrooksyFC View Post
    I'm not too familiar with using the command.
    Now's your chance to become acquainted: "Hello World!" for Microsoft Windows (The Java™ Tutorials > Getting Started > The "Hello World!" Application)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: Class Wasn't Found in Project

    Right, I've done that tutorial. So should I try and code I posted before and do that with the command?

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: Class Wasn't Found in Project

    Quote Originally Posted by BrooksyFC View Post
    Right, I've done that tutorial. So should I try and code I posted before and do that with the command?
    It's up to you. I don't know anything about netbeans, so I've given you several options. You can wait here for somebody to get back to you. You can google the error for more info. Or you could take netbeans out of the equation and compile your classes directly, which is probably what you should be doing anyway, IMHO. Up to you though.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  11. #11
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: Class Wasn't Found in Project

    I'll give it a try. In the mean time I'll see anyone else has another suggestion

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,184
    Rep Power
    20

    Default Re: Class Wasn't Found in Project

    You can't run the code directly.
    I can't remember, but does Netbeans have an applet viewer built in?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: Class Wasn't Found in Project

    NetBeans runs an Applet class in the AppletViewer that comes with the JDK. But not by selecting 'Run' for the project.

    I was going to post a step-by-step of the three ways to run an Applet in NetBeans, but I found that it's more than adequately documented in the online help, so there was no valid reason for this to be asked on a forum.

    Ever tried pressing F1?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  14. #14
    BrooksyFC is offline Member
    Join Date
    Mar 2012
    Posts
    20
    Rep Power
    0

    Default Re: Class Wasn't Found in Project

    I've press F1, what am I looking for in here?

  15. #15
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,184
    Rep Power
    20

    Default Re: Class Wasn't Found in Project

    How about "running an applet"?
    That's what you're trying to do...not run a java application.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 6
    Last Post: 03-01-2012, 04:07 PM
  2. Class not found exception for the servlet class.
    By mazem in forum Java Servlet
    Replies: 2
    Last Post: 08-24-2011, 10:20 AM
  3. class not found
    By meong in forum JDBC
    Replies: 7
    Last Post: 09-22-2010, 12:25 PM
  4. Replies: 11
    Last Post: 07-27-2010, 05:08 PM
  5. Class Not found
    By jitendra in forum AWT / Swing
    Replies: 5
    Last Post: 02-26-2010, 11:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •