Java - error: No se ha encontrado o cargado la clase principal

 
Vista:

error: No se ha encontrado o cargado la clase principal

Publicado por Mauricio Alvarado (1 intervención) el 26/08/2018 00:36:38
Hola, tengo este código. Se compila bien, pero al ejecutarlo me da el error: No se ha encontrado o cargado la clase principal. Ayúdenme por favor. Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package Juego;
 
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Dimension;
 
import javax.swing.JFrame;
 
public class Juego extends Canvas implements Runnable {
 
	private static final long serialVersionUID = 1L;
 
	private static final int WIDTH = 800;
	private static final int HEIGHT = 600;
 
	private static volatile boolean working = false;
 
	private static final String NAME = "Sin Nombre";
 
	private static int ups = 0;
	private static int fps = 0;
 
	private static JFrame window;
	private static Thread thread;
 
	private Juego() {
		setPreferredSize(new Dimension(WIDTH, HEIGHT));
 
		window = new JFrame(NAME);
		window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		window.setResizable(false);
		window.setLayout(new BorderLayout());
		window.add(this, BorderLayout.CENTER);
		window.pack();
		window.setLocationRelativeTo(null);
		window.setVisible(true);
	}
 
	public static void main(String[] args) {
		Juego juego = new Juego();
		juego.begin();
	}
 
	public synchronized void begin() {
		working = true;
 
		thread = new Thread(this, "Graphics");
		thread.start();
	}
 
	public synchronized void stop() {
		working = false;
 
		try {
			thread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
 
	}
 
	private void update() {
		ups++;
	}
 
	private void flash() {
		fps++;
	}
 
	public void run() {
		final int NS_PER_SECOND = 1000000000;
		final byte UPS_TARGET = 60;
		final double NS_PER_UPDATE = NS_PER_SECOND / UPS_TARGET;
 
		long updateReference = System.nanoTime();
		long counterReference = System.nanoTime();
 
		double timeElapsed;
		double delta = 0;
 
		while (working) {
			final long startLoop = System.nanoTime();
 
			timeElapsed = startLoop - updateReference;
			updateReference = startLoop;
 
			delta += timeElapsed / NS_PER_UPDATE;
 
			while (delta >= 1) {
				update();
				delta--;
			}
 
			flash();
 
			if (System.nanoTime() - counterReference > NS_PER_SECOND) {
				window.setTitle(NAME + " || UPS: " + ups + " || FPS: " + fps);
				ups = 0;
				fps = 0;
				counterReference = System.nanoTime();
			}
		}
	}
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

error: No se ha encontrado o cargado la clase principal

Publicado por kingk (108 intervenciones) el 28/08/2018 00:03:53
Hola, si estas usando Eclipse, simplemente vas despliegas el menu del boton para ejecutar, seleccionas Run As, y JavaApplication
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar