47

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

Is there a way to write code to find out?

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

Devoted
  • 177,705
  • 43
  • 90
  • 110
  • 1
    Here is another version of this question: http://stackoverflow.com/questions/557169/find-out-what-jvm-eclipse-is-running-on – ThomasW Jan 29 '13 at 02:29

8 Answers8

74

If you want to check if your -vm eclipse.ini option 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=....

Oliver
  • 741
  • 1
  • 5
  • 2
  • hm for me this shows multiple -vm entries after setting one in eclipse.ini, how can i be sure which one was used? – wutzebaer Sep 18 '20 at 05:30
31

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

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"));
  }
}
David Rabinowitz
  • 29,904
  • 14
  • 93
  • 125
  • 3
    Eclipse doesn't have to run in the default jvm for the system. The ecleipse.ini file can be used to specify a specific jvm for eclipse to run in. But as far as getting the current runtime the system property is the correct way to go. – Carnell Dec 22 '09 at 07:17
  • Cool. Easy and quick way to test. Got to learn a new thing today :) – mtk May 25 '12 at 15:34
  • 4
    -1. This will show the version of Java that your program is configured to run with, not the version that eclipse itself runs with. – JimN Aug 07 '14 at 19:20
  • 2
    @JimN That's true, but from the question contents (rather than the title) it seems this is what Devoted had asked. If the question is indeed about the JRE running the eclipse then Oliver's answer is hte right one – David Rabinowitz Aug 10 '14 at 11:23
14

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.

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

Rites
  • 2,242
  • 5
  • 28
  • 44
6

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.

run java -version command on terminal

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

For that go to

Eclipse >> Preferences >>Java >>Installed JREs

Tushar Diwan
  • 71
  • 1
  • 4
3

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

To find out the version of java that your eclipse project is using, see Project->properties->build path->Libraries tab and 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

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.

2

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.

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.

Dave
  • 618
  • 6
  • 17
2
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.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

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 . . .

Anonymous
  • 1,726
  • 4
  • 22
  • 47