A java file that could be compiled and executed before now gives an error when creating a new directory and changing the hierarchy and position.
There is an error in all four files.

Since it is the 3rd day of our java and the 2nd day of the terra tail, I think there are many points that cannot be reached, but thank you.
Please let me know if you have any information to add.

The declared package "" does not match the expected package "kouki_3.Rep306"
Corresponding source code
class Rep306_1 {
    public static void main (String [] args) {
                    for (int i = 1;i<7;i ++) {
                        for (int j = 1;j<7;j ++) {
                            for (int l = 1;l<7;l ++) {
                                System.out.println (i + "+" + j + "+" + l + "=" + (i + j + l));
What I tried Supplementary information (FW/tool version, etc.)
  • Answer # 1

    The declared package "" does not match the expected package "kouki_3.Rep306"

    Google Translate) Declared package "" does not match expected package "kouki_3.Rep306"

    In Java, the declared package and directory hierarchy must match, but if they don't match, you'll get an error like the one above.
    Before the change, the file was saved directly under the "root directory", so there was no need to declare the package (check "java default package" for details), but after the change, the root directory "Rep306" Since the files are stored in a directory that does not exist, you need to declare the package as follows.

    package kouki_3.Rep306;// Declare the package
    class Rep306_1 {
    // ~ Omitted below ~

    I think I need to study about packaging.

  • Answer # 2

    You should have the tool you are using to compile. For windows, cmd or PowerShell
    Terminal for Mac
    If you type a command there and specify the folder where the java files are, it will probably work.

    The way to move is like the page below.

Related articles