• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Error Writing a Bouncing Ball Program  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My program won't successfully compile when I write my bouncing ball application and I'm not sure where to begin repairs.
Staff note (Liutauras Vilda):

Fixed wrongly used code tags

 
Marshal
Posts: 6255
420
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

David Alcorn wrote:My program won't successfully compile when I write my bouncing ball application and I'm not sure where to begin repairs


As for a start, probably a good idea is to share the compile time error message. Please don't rephrase, but rather copy and paste it - there is important information, which tells you what exactly is wrong.
 
Saloon Keeper
Posts: 5137
54
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is always best to debug the first error first. One error can cause a cascade of other errors so if you clean up the first one often others will go away as well. Keep a close eye on the line numbers in the error messages.
 
David Alcorn
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.NoClassDefFoundError: MyRectangle2D
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: MyRectangle2D
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" C:\Users\School\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 3 seconds)
 
David Alcorn
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiler Error

C:\Users\School\Documents\NetBeansProjects\BouncingBall\src\bouncingball\BouncingBall.java:124: error: cannot find symbol
           public static MyRectangle2D getRectangle(ArrayList list){
 symbol:   class MyRectangle2D
 location: class BouncingBall
C:\Users\School\Documents\NetBeansProjects\BouncingBall\src\bouncingball\BouncingBall.java:132: error: cannot find symbol
           public static MyRectangle2D getRectangle(double[][] points){
 symbol:   class MyRectangle2D
 location: class BouncingBall
C:\Users\School\Documents\NetBeansProjects\BouncingBall\src\bouncingball\BouncingBall.java:67: error: cannot find symbol
               MyRectangle2D rectangle = getRectangle (list);
 symbol:   class MyRectangle2D
 location: class BouncingBall.View
C:\Users\School\Documents\NetBeansProjects\BouncingBall\src\bouncingball\BouncingBall.java:137: error: cannot find symbol
               return new MyRectangle2D((minX+maxX)/2,(minY+maxY)/2,maxX-minX,maxY-minY);
 symbol:   class MyRectangle2D
 location: class BouncingBall
Note: C:\Users\School\Documents\NetBeansProjects\BouncingBall\src\bouncingball\BouncingBall.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors
C:\Users\School\Documents\NetBeansProjects\BouncingBall\nbproject\build-impl.xml:930: The following error occurred while executing this line:
C:\Users\School\Documents\NetBeansProjects\BouncingBall\nbproject\build-impl.xml:270: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 4 seconds)
 
Master Rancher
Posts: 3001
105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi David,

in your code you are referring often to a class called 'MyRectangle2D'. The compiler complains that it cannot find it, and I cannot find it too in your code. Do you have such a class, somewhere?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!