3

I've been working a simple program, and when I run it from the IDE it works 100% as intended, but when I try to compile it using javac from the command line it comes up saying with this:

C:\Users\Lukasz\Documents\NetBeansProjects\NetBeansTest\src\netbeanstest>javac M
ain.java
Main.java:19: error: cannot find symbol
            MainFrame myFrame = new MainFrame();
            ^
  symbol:   class MainFrame
  location: class Main
Main.java:19: error: cannot find symbol
            MainFrame myFrame = new MainFrame();
                                    ^
  symbol:   class MainFrame
  location: class Main
2 errors

However I am unsure what could possibly missing as all of the files are in the same directory. This is what my main looks like:

public class Main {
    public static void main(String[] args) {
            MainFrame myFrame = new MainFrame();
            myFrame.setVisible(true);
    }
}

As you can see it's nothing complicated. Line 19 where the error is MainFrame myFrame = new MainFrame(); but I do not see what could be wrong with it , as it compiles file in the IDE.

Any help here would be very appreciated.

1
  • 1
    Did you compile your MainFrame class ? Commented Sep 4, 2014 at 10:25

2 Answers 2

1

You are compiling Main.java, which has a dependency on MainFrame.java file.

Try compiling and creating a .class file for MainFrame before compiling Main.java

To compile a directory use :

javac dir1/*.java 
Sign up to request clarification or add additional context in comments.

Comments

1

You are only compiling one file. The compiler hasn't been informed about the existence of the file containing the MainFrame class.

1 Comment

That would make sense, how would I go about easily compiling everything in the folder?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.