Eclipse 中运行的是什么版本的 Java?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1944468/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 01:40:16  来源:igfitidea点击:

What version of Java is running in Eclipse?

javaeclipseversion

提问by Devoted

How do I know what version of Java is being run in Eclipse?

我如何知道 Eclipse 中运行的是哪个版本的 Java?

Is there a way to write code to find out?

有没有办法写代码找出来?

Is "JRE System Library [JavaSE-1.6]" in "Package Explorer" the right version?

“包资源管理器”中的“JRE 系统库 [JavaSE-1.6]”是正确的版本吗?

采纳答案by David Rabinowitz

The one the eclipse run in is the default java installed in the system (unless set specifically in the eclipse.ini file, use the -vm option). You can of course add more Java runtimes and use them for your projects

运行 eclipse 的是系统中安装的默认 java(除非在 eclipse.ini 文件中专门设置,请使用 -vm 选项)。您当然可以添加更多 Java 运行时并将它们用于您的项目

The string you've written is the right one, but it is specific to your environment. If you want to know the exact update then run the following code:

您编写的字符串是正确的,但它特定于您的环境。如果您想知道确切的更新,请运行以下代码:

public class JavaVersion {
  public static void main(String[] args) {
    System.out.println(System.getProperty("java.runtime.version"));
  }
}

回答by paxdiablo

String runtimeVersion = System.getProperty("java.runtime.version");

should return you a string along the lines of:

应该按照以下方式返回一个字符串:

1.5.0_01-b08

That's the version of Java that Eclipse is using to run your code which is not necessarily the same version that's being used to run Eclipse itself.

这是 Eclipse 用于运行您的代码的 Java 版本,它不一定与用于运行 Eclipse 本身的版本相同。

回答by Rites

Don't about the code but you can figure it out like this way :

不要关注代码,但你可以这样理解:

Go into the 'window' tab then preferences->java->Installed JREs. You can add your own JRE(1.7 or 1.5 etc) also.

进入“窗口”选项卡,然后首选项-> java-> 已安装的 JRE。您也可以添加自己的 JRE(1.7 或 1.5 等)。

For changing the compliance level window->preferences->java->compiler. C Change the compliance level.

用于更改合规性级别 window->preferences->java->compiler。C 更改合规级别。

回答by Rites

Eclipse uses the default Java on the system to run itself. This can also be changed in the eclipse.inifile in your eclipse install folder.

Eclipse 使用系统上的默认 Java 来运行自己。这也可以在 eclipse 安装文件夹中的eclipse.ini文件中更改。

To find out the version of java that your eclipse project is using, see Project->properties->build path->Libraries taband see the JRE system library thats being used. You can also check it out at Window->Preferences->Java->Installed JREs. This is a list of all JREs that eclipse knows about

要找出您的 eclipse 项目正在使用的 java 版本,请参阅Project->properties->build path->Libraries 选项卡并查看正在使用的 JRE 系统库。您还可以在Window->Preferences->Java->Installed JREs 中查看它。这是 eclipse 知道的所有 JRE 的列表

To find out using code, use the System.getProperty(...)method. See http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()for supported properties.

要找出使用代码,请使用System.getProperty(...)方法。有关支持的属性,请参阅http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties()

回答by Oliver

If you want to check if your -vm eclipse.inioption worked correctly you can use this to see under what JVM the IDE itself runs: menu Help > About Eclipse > Installation Details > Configuration tab. Locate the line that says: java.runtime.version=....

如果您想检查您的-vm eclipse.ini选项是否正常工作,您可以使用它来查看 IDE 本身在什么 JVM 下运行:菜单帮助 > 关于 Eclipse > 安装详细信息 > 配置选项卡。找到显示以下内容的行:java.runtime.version=...

回答by Dave

Under the help menu, there should be a menu item labeled "About Eclipse" I can't say with absolute precision because I'm using STS which is the same thing but my label is different.

在帮助菜单下,应该有一个标有“关于 Eclipse”的菜单项,我不能绝对准确地说,因为我使用的是 STS,它是相同的东西,但我的标签不同。

In the dialog box that opens after you click the relevant about menu item there should be an installation details button in the lower left hand corner.

在单击相关的关于菜单项后打开的对话框中,左下角应该有一个安装详细信息按钮。

The version of Java that you're running Eclipse against ought to be in "System properties:" under the "Configuration" tab.

您运行 Eclipse 所针对的 Java 版本应该在“配置”选项卡下的“系统属性:”中。

回答by SachiN Ware.

try this :

尝试这个 :

public class vm
{
  public static void main(String[] args)
  {
      System.getProperty("sun.arch.data.model") 
  }
}

compile and run. it will return either 32 or 64 as per your java version . . .

编译运行。它将根据您的 Java 版本返回 32 或 64。. .

回答by Tushar Diwan

There are various options are available to test which java version is using your eclipse. The best way is to find first java installed in your machine.

有多种选项可用于测试哪个 Java 版本正在使用您的 Eclipse。最好的方法是找到你机器上安装的第一个java。

run java -version command on terminal

在终端上运行 java -version 命令

then to check whether your eclipse pointing to the right version or not.

然后检查您的日食是否指向正确的版本。

For that go to

为此去

Eclipse >> Preferences >>Java >>Installed JREs

Eclipse >> Preferences >>Java >>Installed JREs