New Posts  All Forums:Forum Nav:

Help with Java Code?

post #1 of 3
Thread Starter 
hey guys im trying to make a brickbreaker type app and for some reason its not working, its for a class and i think ive got the program down but when i run it i always get the error
Code:
load: class Breakout.class not found.
java.lang.ClassNotFoundException: Breakout.class
        at sun.applet.AppletClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.applet.AppletClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.applet.AppletClassLoader.loadCode(Unknown Source)
        at sun.applet.AppletPanel.createApplet(Unknown Source)
        at sun.applet.AppletPanel.runLoader(Unknown Source)
        at sun.applet.AppletPanel.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

Im using eclipse on windows 8 i have java installed i dont know whats wrong with it, GraphicsTools is loaded in my src folder so any help would be appreciated.

heres my original code for those who are interested in known
Code:
import acm.graphics.*;
import acm.program.*;
import java.awt.Color;
import java.util.Random;
import java.util.List;
import java.awt.event.*;


public class Breakout extends GraphicsProgram 
{

        
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        private double paddleX = 0;
        

        public void  mouseMoved(MouseEvent event)
        {
                paddleX = event.getX();
        }
        
        public void run() 
        {
                final int BALLWIDTH = 20;
                final int PADDLEWIDTH = 50;
                final int PADDLEHEIGHT = 10;
                final int INITIALVX = 2;
                final int INITIALVY = 2;
                
                this.setSize(GraphicsTools.WIDTH, GraphicsTools.HEIGHT);
                addMouseListeners();
                
                
                Random r = new Random();
                int x = (GraphicsTools.WIDTH-BALLWIDTH) /2;
                int y = (GraphicsTools.HEIGHT-BALLWIDTH) / 2;
                int vx = INITIALVX;
                int vy = INITIALVY;
                GOval ball = new GOval(x, y, BALLWIDTH, BALLWIDTH);
                ball.setFillColor(Color.RED);
                ball.setFilled(true);
                this.add(ball);
                
                GRect paddle = new GRect(0, GraphicsTools.HEIGHT - PADDLEHEIGHT, PADDLEWIDTH, PADDLEHEIGHT);
                paddle.setFillColor(Color.BLUE);
                paddle.setFilled(true);
                
                List<GRect> l = GraphicsTools.createPlayfield();
                
                l.add(paddle);

                for(GRect e : l)
                        this.add(e);
                
                for(;;)
                {
                                x = (GraphicsTools.WIDTH-BALLWIDTH) /2;
                                y = (GraphicsTools.HEIGHT-BALLWIDTH) / 2;
                                vx = INITIALVX;
                                vy = INITIALVY;

                        for (;;)
        {
            x = x + vx;
            y = y + vy;
         if (x<0)
         {
        vx = -vx;
         }
         if(x>=GraphicsTools.WIDTH-BALLWIDTH)
         {
             vx= - vx;
         }
        if(y<0)
        {
            vy = -vy;
        }
        if(y>=GraphicsTools.HEIGHT-BALLWIDTH)
        {
                x = (GraphicsTools.WIDTH-BALLWIDTH) /2;
                        y = (GraphicsTools.HEIGHT-BALLWIDTH) / 2;
                        vx = INITIALVX;
                        vy = INITIALVY;
        }
                    GRect hit = GraphicsTools.intersect(ball, l);
                    if(hit != null)
                    {
                        GRectangle bb = ball.getBounds();
                        GRectangle bo = hit.getBounds();
                        double bxo = bb.getX() + bb.getWidth() / 2;
                        double byo = bb.getY() + bb.getHeight() / 2;
                        double oxo = bo.getX() + bo.getWidth() / 2;
                        double oyo = bo.getY() + bo.getHeight() / 2;
                        if(bxo < oxo) vx = -Math.abs(vx);
                        if(bxo > oxo) vx = Math.abs(vx);
                        if(byo < oyo) vy = -Math.abs(vy);
                        if(byo > oyo) vy = Math.abs(vy);
                        if(hit != paddle)
                        {
                                l.remove(hit);
                                this.remove(hit);
                        }
                    }
                    ball.setLocation(x, y);
                    paddle.setLocation(paddleX, GraphicsTools.HEIGHT - PADDLEHEIGHT);

                    this.pause(10);
                    if(l.size() == 1){ // paddle is the only thing on the playfield

                        l = GraphicsTools.createPlayfield();

                        l.add(paddle); 
                        for (GRect e: l)
                        {
                                this.add(e);
                        }
                        x = (GraphicsTools.WIDTH-BALLWIDTH) /2;
                        y = (GraphicsTools.HEIGHT-BALLWIDTH) / 2;
                        vx = INITIALVX;
                        vy = INITIALVY;
                        ball.setLocation(x, y);
                        this.pause(500);
                    }
                }
        }
}
}

i cant figure it out for the life of me! any help would be appreciated smile.gif
post #2 of 3
ClassNotFoundException means that your class can't be located. I believe this Stack Overflow question might be of help, particularly since you're working with Eclipse too.
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
MacBook Pro 13"
(6 items)
 
 
Desktop
(13 items)
 
CPUGraphicsRAMHard Drive
Intel i5 3210 @ 2.5 GHz Intel HD4000 4 GB DDR3 @ 1600 MHz 500 GB @ 5400 RPM 
OSMonitor
OSX Mountain Lion 13.3" @ 1280 x 800 
CPUGraphicsRAMHard Drive
Intel i5 480m@2.67GHz AMD Radeon Mobility 5650 4GB DDR3 500GB 
OSMonitor
Windows 7 64bit HP 15.6" 1366x768 
CPUMotherboardGraphicsRAM
E7500 Intel...:( MSI GTS250 1GB 2GB 
Hard DriveOSMonitorPower
250GB Windows XP 17" LG CRT 1280x768@85hz 400W 
  hide details  
Reply
post #3 of 3
Thread Starter 
actually that did not help, but thanks for the link, what i did to solve this for other people that might be having the problem is to create a new project then a class before this i did it in n old project and new class , not sure why this happened but it f ixed it :3
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming