Q:

If I have more files in one project I need to make all fields static?

If I make for example one project. Inside with two class. For example: X and Y. I make them what I want, and I want to make a main method in Y. Only system.out.printlf the values in X and Y. But it writes that I need to make them static if I want to run this. I tried to make a new file with only the main class and inside the X Y values but it showed an error. What I missed?

A:

The main method is declared static 
public static void main(String[] args) {}
Inside of main, it can only access static variables that exist in the enclosing class. You will see this for example with this bit of code:
public class X {
    private int i = 5;

    public static void main(String[] args) {
        System.out.println(i);
    }
}

To make the above work you need to declare i as static:
public class X {
    private static int i = 5;

    public static void main(String[] args) {
        System.out.println(i);
    }
}

A better way would be to do this:
public class X {
    private int i = 5;

    public X() {
        System.out.println(i);
    }

    public static void main(String[] args) {
         new X();    
    }
}

Static methods can only access static methods and other variables declared as static. 
This article may also help you to understand what is going on here.

