- What version of Java is running in Eclipse?
- 8 Answers 8
- Выбор версии Java в Eclipse
- Setup Java/JDK and Eclipse On Window & Linux
- How to check Java version in your machine?
- How to setup Java from Initial?
- Configure Eclipse IDE
- Share this with others:
- Which Java is Eclipse using?
- 5 Answers 5
- How to run Eclipse under different version of JDK or JRE
- 1. Find the JDK / JRE that runs Eclipse
- 2. How to Change JDK / JRE for Eclipse
- Other Eclipse Tutorials:
- About the Author:
What version of Java is running in Eclipse?
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?
8 Answers 8
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=. .
hm for me this shows multiple -vm entries after setting one in eclipse.ini, how can i be sure which one was used?
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:
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.
-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 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
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.
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.
Eclipse >> Preferences >>Java >>Installed JREs
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.
String runtimeVersion = System.getProperty("java.runtime.version");
should return you a string along the lines of:
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.
Выбор версии Java в Eclipse
Для выбора версии Java в Eclipse выберите пункт главного меню Window ➣ Preferences, как показано на картинке ниже.
В следующем окне выберите каталог, в котором установлена, например, JDK 17:
В результате окно станет выглядеть примерно вот так:
Кликните на экранную кнопку “Finish” в правом нижнем углу окна.
В окне “Installed JREs” теперь будет новый пункт с добавленной JDK. Выберите её и кликните на “Apply and Close”:
Теперь вы можете обновить проекты (для проектов Maven комбинация клавиш Alt+F5).
Кроме версии Java, с которой Eclipse собирает и запускает проекты, есть ещё версия Java, на которой он запускается сам.
Это могут быть две абсолютно разные версии. Версия Java, на которой запускается Eclipse, указывается в файле “eclipse.ini”. В самом файле написано обычно что-то вроде:
Setup Java/JDK and Eclipse On Window & Linux
Before creating the Java project, the first thing is to check to JDK installed or not in your machine.
How to check Java version in your machine?
- Go to search
- Type cmd and enter or search for Command prompt
- You will see a black screen for the command prompt as below.
- Type java -version to get detail about it.
The above screen is for the case when java is installed on your screen. If JDK/JRE is not installed on your machine then you will get a message like “Java is not recognized as an internal-external command.”
How to setup Java from Initial?
If JDK/JRE is not set up in your machine then follow below steps:
Download JDK from this site: Download JDK Latest Version
- After downloading click on the .exe file to install
- Follow all steps as the next button and continue as long as a process not complete.
- Default download location for Java will be “C:\Program Files\Java\jdkVerXYZ”
To access Java from command prompts or IDE need to configure environment variables as JAVA_HOME and Path. The value of JAVA_HOME would be home directory path where JDK installed and Path would be (JAVA_HOME/bin)
Follow these steps to configure the environment variables
- Go to Computer ->right click-> Properties -> Advance System Settings->System Variable
- or Go to search type ENV and click on enter.
- Enter that value of JAVA_HOME as below
- Download JDK and untar it.
- Go to your home directory/ sudo directory and set JAVA_HOME and Path in .bashrc file as below:
export JAVA_HOME=/opt/app/ /jdk1.8.0_66
export Path=%JAVA_HOME%/bin:$Path
- Save .bashrc file
- Now run java -version to check configuration is successful.
Configure Eclipse IDE
- Click on the installable of Eclipse IDE.
- Continue the installation by next click.
- Select the path of JDK as installed.
- Select the workspace location for your projects.
Now you are ready to create new projects in Eclipse IDE.
Share this with others:
Which Java is Eclipse using?
I downloaded ‘Eclipse IDE for Java EE Developers’ for Linux from eclipse.org. I am able to write, compile and run Java programs. But I don’t understand what JDK / JRE is being used. If I start a new ‘Java Project’ I can choose which JRE to use, but if I choose for instance ‘JavaSE-1.6’ I still don’t know what that is? Oracle? IBM? And I don’t know where that JRE is in my file system. Let’s say I want to use that same JRE to execute my Java program from command line, how do I find the ‘java’ executable?
Thanks for all the information, however I knew all that already. I know which JRE is being used when I run ‘java’ in the command line. I know that I am using ‘JavaSE-1.6’ in Eclipse because it says so. But I don’t know which implementation of JavaSE-1.6 that is (e.g. Oracle?), and I don’t know how to use that exact implementation to execute smth from command line (where is it on the file system?).
Obviously, if I install JRE myself and set Eclipse up to use that one, I can answer the two above questions. But I don’t know for the defaultly present JREs, e.g. ‘JavaSE-1.6’.
5 Answers 5
- Open Help -> About Eclipse
- click on Installation Details
- select the Tab Configuration
there should be the path to the used JRE.
This is the precise and correct answer to the asked question. This should be marked as accepted answer.
If you want to know where is Java located in you’r system, run it in terminal whereis java .
If you want to know which Java is using in you’r system, run it in terminal which java .
If you want to know what is Java version is using in default, run it in terminal java —version
If you want to know which JDK is using in Eclipse,Refer to Project->Properties->Java Compiler.
If you want to know which JRE is using in Eclipse,Refer to windows->preferences->Installed JREs
It is up to your configuration.
Go to Windows/Preferences, then check:
Java/Installed JREs and Java/Compiler/
You can also override your settings per project: project preferences, Java Compiler.
In case of multiple installation of JDK?Which one eclipse is using? Question is not about which jvm user project/application is using.
(this is too long for a comment)
Let say I want to use that same JRE to execute my Java program from command line, how do I find the ‘java’ executable?
On Linux the java executable is the first executable named «java» found on your path.
. $ echo $PATH /home/f/jdk1.6.0_33/bin:/usr/local/bin:/usr/bin:/bin . $ which java /home/f/jdk1.6.0_33/bin/java
You can install as many JRE/JDK as you want. You can even trivially create user accounts with Java (e.g. a user account for development) and users account without Java (e.g. a user account without Java that you’d use only for browsing the Web [see comment]).
If you try to launch Eclipse when the $PATH doesn’t contain any Java executable and if you didn’t install any JRE/JDK inside ~/eclipse/, then Eclipse shall complain and refuse to launch:
«A JRE or JDK must installed in order to launch Eclipse»
At that point and if you did install Java, you can simply add it to the $PATH and Eclipse shall launch:
. $ export PATH=~/jdk1.6.0_33/bin:$PATH
How to run Eclipse under different version of JDK or JRE
In this article, I will guide you how to change JDK/JRE that runs Eclipse IDE, on Windows operating system. First, you need to know exactly which version of Java on which Eclipse is running.
1. Find the JDK / JRE that runs Eclipse
In Eclipse, click menu Help > About Eclipse IDE. Then in the About Eclipse IDE dialog, click the Installation Details button. Then in the next screen, click Configuration tab. Wait for a moment while Eclipse is retrieving configuration information, and you will see a screen as below:
Find the line that starts with –vm and the value in the next line shows the exact path of JDK/JRE on which Eclipse is running. In the above screenshot, you see Eclipse is running on OpenJDK 11.0.2.
2. How to Change JDK / JRE for Eclipse
You know, Eclipse IDE is written in Java so it needs a JDK/JRE installed to run. By default, the first instance of JDK/JRE found in the PATH environment variable is used to run Eclipse. Consider a typical value of the PATH environment variable like this:
path1;path2;path3;…;%JAVA_HOME%\bin;
In this case, the Java Virtual Machine found in the JAVA_HOME path will run Eclipse IDE. So changing the Java version that run Eclipse is just a matter of updating the value of the JAVA_HOME variable.
However, sometimes it doesn’t work like that. You changed JAVA_HOME points to a newer JDK/JRE, but Eclipse still runs under the old one. Why? What happens?
- An installation of Oracle Java putting its path before your JAVA_HOME, or
- Your Eclipse IDE is configured to stick with a JDK/JRE in its configuration file.
Edit the PATH environment variable on Windows, and you may see a screen as below:
Here, an installation of Oracle Java puts the following line before your JAVA_HOME :
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
That means the JDK/JRE found in this path is always used to run Eclipse. Your JAVA_HOME is ignored. So to change, just move your JAVA_HOME before Oracle’s javapath using the Move Up and Move Down buttons; or delete that Oracle’s javapath. Then restart Eclipse and check configuration again to make sure Eclipse is actually running on the JDK/JRE you specified.
If that doesn’t work, it’s very likely that your Eclipse is somehow configured to stick with a specific version of Java Virtual Machine in its configuration file.
Open the eclipse.ini file in Eclipse’s installation directory in a text editor like Notepad. You may see something like this:
Now, you can change the path after the –vm line to point to a different path of JDK, or delete these two lines to use the Java version specified in the PATH system environment variable.
Phew! That’s how to change the version of Java virtual machine that powers your Eclipse IDE. I hope you found this article helpful.
You can also watch the video version below:
Other Eclipse Tutorials:
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.