Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda