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 6 of 6

Thread: MouseEventDemo

  1. #1
    Junior Member
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MouseEventDemo

    Oracle's MouseEventDemo.java does not compile.
    I get error message "Cannot find BlankArea class"
    BlankArea class exists in same folder as MouseEventDemo.
    I'm stumped.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,707
    My Mood
    Mellow
    Thanks
    230
    Thanked 704 Times in 690 Posts

    Default Re: MouseEventDemo

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    While not all Oracle tutorials have all of the parts in one place that are necessary to simply copy, paste into an editor, and compile successfully, most do or at least indicate where to get the required parts. I think the problem is probably at your end in the way the project is/isn't set up. Post the code exactly as you tried to run it and the entire error message, copied from exactly as it appears at your end.

  3. #3
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: MouseEventDemo

    Quote Originally Posted by JohnRawson View Post
    Oracle's MouseEventDemo.java does not compile.
    I get error message "Cannot find BlankArea class"
    BlankArea class exists in same folder as MouseEventDemo.
    I'm stumped.
    How do you compile? From an IDE? Or manually with JDK tools from command prompt? If the latter, it may be a "classpath" problem. Do you know what is the classpath and how to set it? If not, see How Classes are Found
    (in any way, this is a thing to know, if you want to be a java programmer )
    Andrea, www.andbin.net SCJP 5 (91%) SCWCD 5 (94%)

    Useful links for Java beginners My new project Java Examples on Google Code

  4. #4
    Junior Member
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MouseEventDemo

    I compile from the command prompt using the JDK tools.
    I have set the class path.
    I think that I have copied the demo exactly.
    BlankArea.java compiled as did MouseEventDemo.java.
    I come to Java from Python where I would just import BlankArea.
    The error message I get when I try to run it is
    Exception in thread "main" java.lang.NoClassDefFoundError:MouseEventDemo(wron g name:events/MouseEventDemo)

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,940
    Thanks
    51
    Thanked 2,267 Times in 2,239 Posts

    Default Re: MouseEventDemo

    Exception in thread "main" java.lang.NoClassDefFoundError:MouseEventDemo(wron g name: events/MouseEventDemo)
    That says there is a package: events. Put the class file in a folder named events, go to the folder containing the events folder and enter:
    java events.MouseEventDemo

    Or remove the package statement and do it like you did before.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: MouseEventDemo

    Thanks.
    I have learned all about packages.
    It now works fine