IntelliJ IDE(社区版本)不支持var声明Java 10 [英] IntelliJ IDE (Community Version) doesn't support var declaration Java 10

查看:306
本文介绍了IntelliJ IDE(社区版本)不支持var声明Java 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 IntelliJ IDEA(社区版) 2018.1版,其中增加了对 Java 10 的支持.

I've installed the version 2018.1 of IntelliJ IDEA (COMMUNITY EDITION), which added support for Java 10.

当我尝试使用新的"var" 键入本地变量时,IDE用红色和可爱的短语无法解析类型"var"突出显示它.请参阅附件 varRed

When I tried to use new "var" to type local variable, the IDE highlights it with red colour and the lovely phrase: "Cannot resolve the type "var". Please see attachment varRed

我读了另一篇帖子,该帖子发生在与成员给出可能的解决方案完全相同的问题上 https://stackoverflow.com /a/49719734/9478809

I've read another post that happens exactly the same issue in which a member gave a possible solution https://stackoverflow.com/a/49719734/9478809

我也这样做了,我已经为该类型的Java语句创建了一个实时模板,但是它仍然无法正常工作.

I've done that as well, I've created a live template for that type for Java statement but it still doesn't work.

你们当中有人对此有何建议? 感谢您的帮助

Some of you got any suggestion for that? I will appreciate your help

预先感谢.

Thanks in advance.

推荐答案

要扩展nullpointer的注释,您需要验证以下几点:

To expand on nullpointer's comment, there are a few things you need to verify:

  1. 确保已下载了更新的SDK(版本10或更高版本).我建议使用sdkman安装SDK,因为它有助于管理多个版本. SDKMAN
  2. cmd ; 打开项目结构
  3. 对于Project SDK,请选择更新的Java SDK
  4. 对于项目语言级别,选择相应的级别
  5. 现在导航至模块",并确保在此处也选择了正确的语言级别.我建议选择默认项目",以避免将来造成混乱.
  1. Make sure you've downloaded an updated SDK (version 10 or higher). I recommend using sdkman to install the SDK because it helps manage multiple versions. SDKMAN
  2. Hit cmd; to open Project Structure
  3. For Project SDK, select your updated java SDK
  4. For Project language level, select the corresponding level
  5. Now navigate to Modules, and make sure the correct language level is selected here too. I recommend selecting "Project default" to avoid future confusion.

作为故障排除步骤,使用maven或gradle在命令行上进行编译以确保它是IDE配置问题也很有帮助.

As a troubleshooting step, it's also helpful to compile on the command line with maven or gradle to make sure it is an IDE configuration issue.

这篇关于IntelliJ IDE(社区版本)不支持var声明Java 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆