Why sysout won't work?

68,742

Solution 1

Eclipse > Preferences > Java > Editor > Content Assistant > Advanced

Make sure Template Proposals is checked in one of the shown lists.

Solution 2

In recent version of Mac (10.14.1) , Mac OS Settings --> Keyboard --> Shortcuts(tab) --> Input sources.

uncheck the setting ctrl +Space.

Now go to Eclipse IDE and it should work.

Solution 3

You have to press Ctrl + Space for the sysout (or equivalently: syso) shortcut to work in Eclipse, as sysout is not part of Java in anyway, on the contrary: it's an abbreviation introduced in Eclipse that only works after you press Ctrl + Space and expands to System.out.println().

By the way, syserr (or equivalently: syse) will expand to System.err.println() after pressing Ctrl + Space.

Solution 4

public static void main(String[] args)

This public static void ... blah blah has to be put for the sysout to work

Solution 5

After trying all the answers above with no success I found another reason why Ctrl+Space could be prevented from working.

In my instance Ctrl+Space worked for some projects in the workspace but not others. I discovered that the project that it did not work for did not have the jdk in the build path, instead it had the jre for the application server (weblogic 12). The application ran fine on the server but Ctrl+Space to open the template proposals didn't work and other things like syntax highlighting were not quite right.

I hope this helps anyone who comes to this questions 3 years after it was asked (Like I did).

Share:
68,742

Related videos on Youtube

Zoe
Author by

Zoe

Updated on July 09, 2022

Comments

  • Zoe
    Zoe 6 months

    I checked the preferences settings in my Eclipse, it's all set to default with sysout option on, but when I typed sysout in eclipse, it won't automatically go into System.out.println(). I've checked several other related topics which mention ctrl + space. It is a shortcut for input method on my computer. I don't know if this is related to my unable to use the sysout. If not, please let me know how I can get my sysout working. If yes, please kindly let me know how I can reset 'ctrl + space' or set other shortcut for content assistant.

    • jlordo
      jlordo over 9 years
      type sysout and hit ctrl + space and it will become System.out.println();. This will only work in places were it's legal to write System.out.println();, so it won't work directly in the class body, you have to be in a method, constructor or (static) initializer block.
    • Jesper
      Jesper over 9 years
      Are you in the Java perspective? Keyboard shortcuts sometimes change if you're in another perspective. Are you editing a Java source file?
    • Erran Morad
      Erran Morad over 8 years
      If you accidentally try to put a print statement ouside of a method or code block using sysout + ctrl + space, then you obviously won't be able to use sysout and you will see this message : Sysout - method stub.
  • Zoe
    Zoe over 9 years
    I think my Ctrl + Space is a different function from yours. Whenever I hit ctrl + space, it change to a different input method (eg. Chinese)
  • Óscar López
    Óscar López over 9 years
    @Zoe looks like a modified Eclipse configuration, the default functionality for Ctrl + Space is autocomplete. Take a look at the keyboard shortcuts and see how's mapped autocomplete, and change it to suit your taste. Look in Eclipse's help, the exact location of the option might have changed between versions and it's better if you refer to your own version's documentation
  • Gary
    Gary over 6 years
    I think you mean it has to be inside a valid method.

Related