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.
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.
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.
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.
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
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)
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:Exception in thread "main" java.lang.NoClassDefFoundError:MouseEventDemo(wron g name: events/MouseEventDemo)
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.
Thanks.
I have learned all about packages.
It now works fine