takesides takesides - 1 year ago 87
Java Question

System.out is not recognised

This is driving me absolutely crazy. I have a package that was working fine, then I renamed the package and now I cannot use

(or anything in the
class). For what it's worth here is my
class (I've removed EVERYTHING except the
line just in case something else was causing the issue).

package goldminetosugarconvertor;

public class Main
public static void main(String[] args)
System.out.println("prog init");

In NetBeans the
is underlined with an error
"cannot find symbol"
but the weird thing is it shows the location as "class
" which is obviously wrong.

Any bright ideas? I am guessing that something got broken when I renamed the package but I just can't figure out what would break so bad that
was not recognised.

Answer Source

You must have a System class in the package goldminetosugarconvertor. When you changed whatever the old package Main was apart of to this one, you've now shadowed System from java.lang with goldminetosugarconvertor.System.

Unless you remove this System class, you'll have to prepend System.out with java.lang., ie:

java.lang.System.out.println("prog init");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download