var关键字未在JDK 10中重新协调 [英] var keyword not reconized in JDK 10

查看:330
本文介绍了var关键字未在JDK 10中重新协调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功安装了带有JDK 10的netbeans(Apache版本),但在我的项目中不能使用 var 关键字,它一直说不能找到符号。任何帮助,将不胜感激。

I have installed netbeans (Apache version) with JDK 10 successfully, but can't use var keyword in my project, It keep saying cannot find symbol. Any help would be appreciated.

推荐答案

使用 JDK 10 <的 var 关键字/ strong>在NetBeans中:

To use the var keyword with JDK 10 in NetBeans:


  • 确保您运行最新版本的Apache NetBeans

  • 在NetBeans中,将 JDK 10 添加为Java平台(工具> Java平台>添加平台... )。没有必要使 JDK 10 成为默认值。

  • 创建一个简单的Java应用程序(文件>新建项目...> Java> Java应用程序)并声明 var 变量(例如 var v = 7; )在 main()方法中。

  • 项目窗格中选择项目节点,右键单击并选择属性

  • 项目属性中窗口确保库> Java平台设置为 JDK 10

  • 项目属性中窗口确保来源>来源/二进制格式设置为 JDK 10

  • 文件窗格中打开文件 project.properties (在 nbproject 文件夹下)并导航到 javac.source 和<的行code> javac.target 。确认它们都包含值 10

  • Shift-F11 清除并构建项目。

  • Ensure that you are running the latest version of Apache NetBeans.
  • In NetBeans add JDK 10 as a Java platform (Tools > Java Platforms > Add Plaform...). It is not necessary to make JDK 10 the default.
  • Create a simple Java application (File > New Project... > Java > Java Application) and declare a var variable (e.g. var v = 7;) within the main() method.
  • Select the project node in the Projects pane, right click and select Properties.
  • In the Project Properties window ensure that Libraries > Java Platform is set to JDK 10
  • In the Project Properties window ensure that Sources > Source/Binary Format is set to JDK 10
  • In the Files pane open the file project.properties (under the nbproject folder) and navigate to the lines for javac.source and javac.target. Verify that they both contain the value 10.
  • Press Shift-F11 to clean and build the project.

如果仍有找不到符号错误var 声明然后NetBeans安装存在根本性的错误,因此请使用以下命令更新OP:

If there is still a "cannot find symbol" error for the var declaration then there is something fundamentally wrong with the NetBeans installation, so update the OP with:


  • 内容执行清理和构建后的输出窗口。

  • 正在编译的源。

  • javac.source 和<$ c的设置 project.properties 中的$ c> javac.target 。

  • 帮助>关于中显示的版本信息强>窗口。

  • The content of the Output window after doing the Clean and Build.
  • The source being compiled.
  • The settings for javac.source and javac.target in project.properties.
  • The version information shown in the Help > About window.

这篇关于var关键字未在JDK 10中重新协调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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