简体   繁体   English

设置eclipse java SE-1.7

[英]Setup eclipse java SE-1.7

I wanted to start learning java but Eclipse is giving me some trouble. 我想开始学习java,但Eclipse给了我一些麻烦。

First of all I'm a beginner with Java with little to no knowledge about it. 首先,我是Java的初学者,几乎不知道它。 I want to use 'JavaSe-1.7'. 我想使用'JavaSe-1.7'。 I have no clear reason to use it besides using the latest version. 除了使用最新版本之外,我没有明确的理由使用它。 After downloading Eclipse (Eclipse IDE for Java Developers) I created a new Java project and selected 'use an execution eviorment JRE : JavaSE-1.7'. 下载Eclipse(Eclipse IDE for Java Developers)之后,我创建了一个新的Java项目并选择了“使用执行eviorment JRE:JavaSE-1.7”。 This directly popped the notification saying 'The default compiler compliance level for the current workspace is 1.6. 这直接弹出通知说'当前工作空间的默认编译器合规性级别为1.6。 The new project will use a project specific compiler compliance level of 1.7.'. 新项目将使用项目特定的编译器合规级别1.7。 I finished creating the project and started following some tutorials. 我完成了项目的创建并开始学习一些教程。

However I noticed directly I have 2 errors which dont explain anything or have a source. 但是我直接注意到我有2个错误,没有解释任何东西或有源。 I ignored it and started typing and tried to import 'java.io.console' however it said 'The import java.io cannot be resolved' and I have no idea what is the cause of it neither how to fix this. 我忽略了它并开始输入并尝试导入'java.io.console',但它说“导入java.io无法解决”,我不知道它的原因是什么,如何解决这个问题。

Would like some instructions into the right direction. 想要一些指示正确的方向。

Thanks in advance 提前致谢

Check your Eclipse preferences: Java -> Installed JREs. 检查Eclipse首选项:Java - >已安装的JRE。 The one that you're using should be marked and it should be a JDK not just a JRE. 您正在使用的那个应该被标记,它应该是JDK而不仅仅是JRE。

Also check your project's build path: Right click on the project -> Properties -> Java Build Path Check in the "libraries" folder whether the JRE System Library is present and if not add it using "Add library"->"JRE System Library" and then select the correct one (from an installed JDK). 还要检查项目的构建路径:右键单击项目 - >属性 - > Java构建路径检查“libraries”文件夹中是否存在JRE系统库,如果不是,则使用“添加库” - >“JRE系统库”添加它“然后选择正确的(来自已安装的JDK)。

You may not have your JDK/JRE set up correctly. 您可能没有正确设置JDK / JRE。

Check the following: 检查以下内容:

  • Did you install a JDK or just the JSE? 你安装了JDK还是只安装了JSE? The JDK is needed to compile .java files to .class files. 需要JDK将.java文件编译为.class文件。 Without it, you can only run java programs, not develop them. 没有它,你只能运行 java程序,而不是开发它们。 If not, download and install it from Oracle website. 如果没有,请从Oracle网站下载并安装它。

  • Check in Eclipse, if you have the JRE installed there as well. 检查Eclipse,如果你也安装了JRE。 You just need to specify the path to the installation. 您只需指定安装路径即可。 You can reach this screen via the "Window->Prefrences" menu. 您可以通过“Window-> Prefrences”菜单访问此屏幕。 see this screenshot: 看这个截图:

在此输入图像描述

The message you receive about project specific compiler compliance level is not a problem, it just means that your workspace is set up to comply to java 1.6 but your project will comply to java 1.7 standards. 您收到的有关项目特定编译器合规性级别的消息不是问题,它只是意味着您的工作区设置为符合java 1.6,但您的项目将符合java 1.7标准。 Also, Java 7 in general is no problem whatsoever. 而且,Java 7通常没有任何问题。

Paths may differ, especially if you're not running a *nix OS. 路径可能不同,特别是如果您没有运行* nix操作系统。 Just point the location to where you installed your JDK. 只需将位置指向安装JDK的位置即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM