• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

203
Vistas
Eclipse Java - Running FIle issues; Im new around here

I have the following code:

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.Renderer;
import javax.swing.Timer;


// All packages imported , ready for use... Add more if need be : +



@SuppressWarnings("unused")
public class main implements KeyListener, ActionListener 
{
    public boolean board_show =true;
    public int AOB1 = 16;
    public int AOB2 = 16;

    public static int WOB = 640;
    public static int HOB = 640;

    public int GStat = 0;
    // Defines when game is playing, toggle-able twice 0, 1, 2
    // 0 = Menu, 1 = Paused, 2 = Game
    // Might Become Redundant
    // TODO Make this feature redundant!


    public boolean click, space;
    public int turn;
    public Component renderer;


    public void ScreenUp()
    {
        Timer timer = new Timer(20, this);
        JFrame jframe = new JFrame("CHESS");

        jframe.setSize(WOB, HOB);
        jframe.setVisible(true);

        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jframe.add(renderer);
        jframe.addKeyListener(this);



        timer.start();


    }

    public static void render(Graphics g)
    {
        g.setColor(Color.black);
        g.fillRect(0, 0, WOB, HOB);
    }

    @Override
    public void actionPerformed(ActionEvent arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void keyPressed(KeyEvent arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void keyReleased(KeyEvent arg0) {
        // TODO Auto-generated method stub

    }
    @Override
    public void keyTyped(KeyEvent arg0) {
        // TODO Auto-generated method stub

    }

}

And I want to know why Eclipse, my editor will not let me run this file, as a whole, even in other modes it comes up with errors. I am fairly new to Java, so I am trying to make a Game - Chess. For now I just want to know why the editor will not let me run it and how I can run it. And of course, since I am new to Java, I only know the basics of the language, so any detailed response would be greatly appreciated!

over 3 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You expect that having a class named main is enough to define an entry point to run a Java application. Wrong.

You need a method with exactly this signature

public static void main(String[] args) {

in your class. That method defines what happens when you "run" the class/application.

And the real answer is: study those tutorials written for people ... that just "start" with Java, like the one from Oracle. Even when you are proficient in other languages - when you just assume how things work; chances are that you run into exactly this kind of problems.

over 3 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda