Why sysout won't work?

2019-02-13 07:59发布

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.

14条回答
对你真心纯属浪费
2楼-- · 2019-02-13 08:13

In my case it didn't work because ctrl+space was being used by another program Ubuntu(I-Bus) in my case ref. here Try changing ctrl-space by another key combination in general->keys to find out if this is causing the problem.

查看更多
冷血范
3楼-- · 2019-02-13 08:19

Select in the menu bar "Window > Preferences > Java > Editor > Templates" deselect at the lower end of window: "Use code formatter"

enter image description here

查看更多
老娘就宠你
4楼-- · 2019-02-13 08:21

For me sysout in eclipse created in two lines. println() in new line..Then I found myself how to avoid this and get System.out.println in one line ..go to Windows > Preferences > Java->Templates (or type templates on search field in top left corner box).Then In template configuring section uncheck "use code formatter"..thats it.. :)

System.out
         .println();
查看更多
对你真心纯属浪费
5楼-- · 2019-02-13 08:26

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).

查看更多
Viruses.
6楼-- · 2019-02-13 08:30
public static void main(String[] args)

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

查看更多
Viruses.
7楼-- · 2019-02-13 08:31

I had the same problem. I had ctrl + Space used as a shortcut for input source in Mac. To disable this go to settings -> Keyboard -> Input Sources and uncheck Select the previous source. Than syso shortcut will work.

查看更多
登录 后发表回答