None of the answers to this common question solve my problem.
I have a file directory tree like such
root
|
+--> com
|
+--> Game.java
+--> Window.java
I compiled Game.java
and Window.java
sucesffully and the resulting tree is like so
root
|
+--> com
|
+--> Game.java
+--> Game.class
+--> Window.java
+--> Window.class
I changed directory back to root and ran the following command from the osx terminal
java com.Game
and the I received the following error
Could not find or load main class
I'm not sure why, here are my classes
Game.java
package com;
import java.awt.*;
public class Game extends Canvas implements Runnable {
private static final long mSerialVersionUid = -240870510533527854L;
public static final int WIDTH = 640, HEIGHT = WIDTH / 12 * 9;
public Game(){
new Window(WIDTH, HEIGHT, "Let's build a game!", this);
}
public synchronized void start(){
}
@Override
public void run(){
}
public static void main(String[] args){
}
}
Window.java
package com;
import java.awt.Canvas;
import javax.swing.JFrame;
import java.awt.Dimension;
public class Window extends Canvas {
public Window(int width, int height, String title, Game game){
JFrame frame = new JFrame(title);
frame.setPreferredSize(new Dimension(width, height));
frame.setMaximumSize(new Dimension(width, height));
frame.setMinimumSize(new Dimension(width, height));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.add(game);
frame.setVisible(true);
game.start();
}
}