Results 1 to 9 of 9
  1. #1
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default What's wrong with this program?

    First_Cup.java
    ----------------------------------------------------------------------------

    import java.awt.Rectangle;

    public class First_Cup {

    public static void main(String[] args){
    Rectangle cerealBox = new Rectangle(5,10,20,30);
    cerealBox.translate(15,25);
    System.out.println(cerealBox);
    System.out.println("First Cup!");
    }
    }

    I could compile this program successfully; but the byte code could not possibly run.
    I have no idea why it could not run. Could somebody tell me why?

    Runtime Error Message:

    Exception in thread "main" java.lang.NoClassDefFoundError: First_Cup/class

    Could not find the main class: First_Cup.class. Program will exit.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default Re: What's wrong with this program?

    I bet you tried to run it as
    Java Code:
    java First_Cup.class
    Don't do that and read the tutorials how you are supposed to run your class.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: What's wrong with this program?



    I have run the command already; yet it still does not work.

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default Re: What's wrong with this program?

    Quote Originally Posted by java_aim View Post


    I have run the command already; yet it still does not work.
    "does not work" is not a very detailed problem description.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: What's wrong with this program?

    The newly received message:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: First_Cup : Unsupported major.minor version 51.0

    ...

    Could not find the main class: First_Cup. Program will exit.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default Re: What's wrong with this program?

    Quote Originally Posted by java_aim View Post
    The newly received message:

    Exception in thread "main" java.lang.UnsupportedClassVersionError: First_Cup : Unsupported major.minor version 51.0

    ...

    Could not find the main class: First_Cup. Program will exit.
    Type this:

    Java Code:
    javac -version
    java -version
    and show us the results; I suspect that you're using different versions for compilation and running the stuff.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: What's wrong with this program?

    Sorry. It's just worked.

  8. #8
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,349
    Blog Entries
    7
    Rep Power
    20

    Default Re: What's wrong with this program?

    Quote Originally Posted by java_aim View Post
    Sorry. It's just worked.
    Care to explain what you did to fix it?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    java_aim is offline Member
    Join Date
    Oct 2011
    Posts
    15
    Rep Power
    0

    Default Re: What's wrong with this program?

    I just reinstalled JDK. :D (1.7)

Similar Threads

  1. What is wrong with this program!?
    By flecdorbee in forum New To Java
    Replies: 5
    Last Post: 02-26-2011, 01:11 AM
  2. what the wrong in my program ><
    By MSs.Java in forum New To Java
    Replies: 4
    Last Post: 05-03-2010, 01:28 PM
  3. Wrong Order in Program Run
    By HeatR216 in forum New To Java
    Replies: 0
    Last Post: 03-25-2010, 08:41 PM
  4. What's wrong in my program...?
    By Annatar in forum Java Software
    Replies: 3
    Last Post: 10-31-2008, 06:03 AM
  5. what is wrong with this program ?
    By Poor Bee in forum New To Java
    Replies: 1
    Last Post: 05-07-2008, 07:23 PM

Posting Permissions

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