I have this problem where I can't use another class inside the same package. Here is the code:
package Main;
public class App {
public App() {
new GUI();
}
public static void main(String[] args) {
new App();
}
}
And here is the command that I use to run the application:
cd "c:\Save_File_Program\Java\FinalProject\src\Main\" ; if ($?) { javac App.java } ; if ($?) { java App }
App.java:5: error: cannot find symbol
new GUI();
^
symbol: class GUI
location: class App
1 error
I do have GUI.java inside Main package, same as App.java. This problem occured after I tried to connect mysql with java using JDBC.
The steps that I followed is: download mysql-connector-java.jar, copy the jar to "C:\Program Files\Java\jre1.8.0_331\lib\ext\mysql-connector-java-8.0.29.jar", and make a new system variable named "CLASSPATH" with a value to the jar path.
Any help is greatly appreciated. Thank you.
I think the problem is, that your code references a class from a different file, that javac does not know about. It should work if you call javac
with all required files. In your case either javac *.java
or javac App.java GUI.java Menu.java
.