Question

I am trying to compile a program in java using the command prompt. My program runs fine in eclipse, however, when I try to compile it in command prompt I received an error message. Any help and direction would be much appreciated.

This is my main program that calls the class Loop. import logic.Loop;

public class Triton {

    Loop loop = new Loop();

    loop.setPreferredSize(new Dimension(600, 600));
    loop.setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
    loop.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

    JFrame frame = new JFrame(TITLE);
    frame.add(loop);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    device = environment.getDefaultScreenDevice();
    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

This is my Loop class

package logic;

public class Loop extends Canvas implements Runnable{
    rest of my code goes here...
}

When I compile the code in command prompt I am in the directory containing the main class and I try to compile using javac Triton.java This is the error I get.

Triton.java:9: error: package logic does not exist import logic.Loop;

Triton.java:20: error: cannot dind symbol Loop loop = new Loop();

symbol: class Loop location: class Triton Trion.java:20: error: cannot find symbol Loop loop = new Loop(); sybmol: class Loop location: class Triton 3 errors

Était-ce utile?

La solution

It looks like Loop was imported via eclipse and isn't in the build itself. Therefore it can't reference it outside of eclipse. Essentially, your compiler is compiling Triton without pulling the Loop dependency.

Try javac Loop.java Triton.java

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top