Results 1 to 2 of 2
  1. #1
    JavaNinja is offline Member
    Join Date
    Jul 2015
    Posts
    8
    Rep Power
    0

    Default HELP ME. I can't run my java code in eclipse

    when i try to run my code in eclipse it just says there is this selection can not be launched or when i try to run the whole package as an applet it says this selection doesn't contains an applet
    Java Code:
    Java Code:
    package spaceXplorerCode;
     
    import java.awt.BorderLayout;
    import java.awt.Canvas;
    import java.awt.Dimension;
     
    import javax.swing.JFrame;
     
    public class MainGameBootFile extends Canvas implements Runnable {
     
        private static final long serialVersionUID = 1L;
        public static final int WIDTH = 160;
        public static final int HEIGHT = WIDTH / 12 * 9;
        public static final int SCALE = 3;
        public static final String NAME = "UniCreator";
        private JFrame frame;
     
        public boolean running = false;
     
        public MainGameBootFile() { // This sets the games dimensions and starts it
                                    // up.
     
            setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
            setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
            setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
     
            frame = new JFrame(NAME);
     
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Closes the
                                                                    // Window.
            frame.setLayout(new BorderLayout());
     
            frame.add(this, BorderLayout.CENTER);
            frame.pack();// Sets the size to the preferred size.
     
            frame.setResizable(false); // This code sets it that the game can't be
                                        // resizable
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
     
        public synchronized void start() {
            new Thread(this).start();
            running = true;
        }
     
        public synchronized void stop() {
     
            running = false;
     
        }
     
        public void run() {
            long lastTime = System.nanoTime();
            double nsPerTick = 10000000D / 60D;
     
            int frames = 0;
            int ticks = 0;
     
            long lastTimer = System.currentTimeMillis();
            double delta = 0;
            while (running) {
                System.out.println(frames +","+ ticks);
                long now = System.nanoTime();
                delta += (now - lastTime) / nsPerTick;
                lastTime = now;
                boolean shouldRender = false;
                 
                while (delta >= 1) {
                    ticks++;
                    tick();
                    delta -= 1;
                    shouldRender = true;
                }
                if (shouldRender){
                frames++;
                render();
                }
                if (System.currentTimeMillis() - lastTimer >= 1000) {
                    lastTimer += 1000;
                    frames = 0;
                    ticks = 0;
                }
            }
        }
     
        public void tick() {
     
        }
     
        public void render() {
     
        }
     
        public void main(String[] args) {
            new MainGameBootFile().start();
        }
     
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: HELP ME. I can't run my java code in eclipse

    Please don't post the same problem multiple times.

    I'm closing this one as I answered in your other thread.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 2
    Last Post: 10-11-2013, 09:26 AM
  2. Replies: 0
    Last Post: 09-09-2011, 11:04 AM
  3. help to run java Qr Code by eclipse
    By elaseef in forum Eclipse
    Replies: 1
    Last Post: 08-13-2009, 08:56 PM
  4. how to debug java code in eclipse
    By rajesh058 in forum Advanced Java
    Replies: 3
    Last Post: 07-25-2007, 11:19 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
  •