您的位置:首页 > 编程语言 > Java开发

设置Eclipse: 开启assertion/设置tab缩进为空格

2017-03-10 10:48 218 查看
这篇文章引自MIT公开课 6.005 — Software Construction on MIT OpenCourseWare, 链接为 https://ocw.mit.edu/ans7870/6/6.005/s16/getting-started/

1 Open Eclipse preferences.

Windows & Linux : go to Window → Preferences .

OS X : go to Eclipse → Preferences .

2 Make sure Eclipse is configured to use Java 8

In preferences, go to Java → Installed JREs . Ensure that “Java SE 8” or “1.8.0_71” is the only one checked. If it’s not listed, click Search.

Go to Java → Compiler and set “Compiler compliance level” to 1.8. Click OK and Yes on any prompts.

3 Make sure assertions are always on .

Assertions are a great tool for keeping your code safe from bugs, but Java has them off by default.

In preferences, go to Java → Installed JREs . Click “Java SE 8”, click “Edit…”, and in the “Default VM arguments” box enter: -ea (which stands for enable assertions ).

4 Tab policy .

Configure your editor to use spaces instead of tabs, so your code looks the same in all editors regardless of how that editor displays tab characters.

In preferences, go to Java → Code Style → Formatter . Click the “Edit…” button next to the active profile.

In the new window, change the Tab policy to “Spaces only.” Keep the Indentation size and Tab size at 4. To save your changes, enter a new “Profile name” at the top of the window and click OK.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: