Change enviornment to JDK in Eclipse Luna - eclipse

I am using Eclipse Luna (Java EE IDE). I need to add jdk because my project is been converted to maven. Whenever , I install maven console gives an error
No compiler is provided in this environment. Perhaps you are running
on a JRE rather than a JDK?
So i used Preference>installed jre's. However , when i am trying to change JRE to JDK by using Search button in Installed jre's. It shows me only JRE not JDK. Although , i am providing JDK path.
In short , I need to change my environment to JDK.
Thanks. Please help me out

In the preferences screen, remove the JRE listed there.
Add > Standard VM + Next > Directory + navigate to the jre directory inside jdk folder and Finish
If done right then JRE Home should look like "C:\Program Files\Java\jdk1.8.0_05\jre", NOT "C:\Program Files\Java\jre8"
Next, make sure you have the new JRE System Library listed under the Libraries tab in Java build path and in the Java Compiler (right click on project > properties) you define enable project specifics and set Compiler compliance level to the version you want.
Hope it helps.

Just open: Window-> Preferences ->Installed JREs and press SEARCH. Chose a folder and eclips find all avaliable jre and sdk.

Related

Automatically linking Java 8 source code with Eclipse IDE

In my installation of Eclipse IDE (Mars 4.5) it has not automatically linked rt.jar and jfxrt.jar to src.zip and javafx-src.zip. I know how to do this manually by browsing to the .zip files within the JDK installation.
What I want to know is if there is a way to ensure this happens automatically when installing Eclipse / Java. I'm pretty certain I know someone who didn't link to the source manually and it is linked on their installation.
For example, if you install the JDK before Eclipse, or vice-versa, does this make any difference?
Also, when you make the link, where abouts is the preference information stored on the file system - is it somewhere within the same folder that eclipse.exe exists?
To make sure that Eclipse is running in your JDK instead of a JRE (The JDK installation typically puts a JRE on the system executable path), you should always specify it via eclipse.ini. The -vm option described there tells Eclipse exactly what JVM you want it to run in.
Another option is to add the JDK to the Installed JREs section of your Eclipse preferences and set that as the default for all projects. The default JVM used for projects is the same as the one Eclipse itself runs in, so you don't necessarily need to do both.
Once you have the JDK set as the default JVM, you can open a project's Properties, select Java Build Path section, then look at the Libraries tab. You should see your JDK as the JRE System Library, including its rt.jar and corresponding source attachment. Like this:

Using both jdk 1.6 and jdk 1.7 for different projects in Eclipse

I am using Eclipse with JDK 1.7. My previous projects are developed in java 7 and JDK 1.7.
Now, I want to build a new project under JDK 1.6 in Eclipse. Is it possible to do that so that some projects are based on JDK 1.7 and some others are based on JDK 1.6 without conflicts?
If this can be done, please let me know how to do it step by step.
Update:
My default JDK is 1.7. I created a new project that is based on jdk1.7 by default. And then I go to the property of this project, and then java compiler, then change the compliance settings as the image shows below. But there is some error occurred. What could be the reason causes this error?
The following is the "problem" view
After some research, I have solved this problem. please see the reference about how to fix the facet version.
You can set overall workspace properties to use one version of Java and set individual project properties to use another.
To set overall workspace properties, click on Window > Preferences, then navigate to Java > Compiler.
To set project properties, right-click on the project and select Properties. Navigate to Java Compiler and check "Enable project specific settings"
You can choose from among the installed JREs for either setting. To tell Eclipse about a newly installed JRE, you can open the workspace preferences and navigate to Java > Installed JREs and then click the "Add" button.
You can change the JDK used by project under Project properties(alt+enter)-> Installed JREs. Also Debug Configuration is your friend. You can set what JDK to use when launching/running an app/program in Eclipse.
This can be done for an Eclipse Run Configuration. You may define multiple such configurations, each of which will reference a "main class" in one of your projects.
In Window -> Preferences -> Java -> Installed JREs define a location for each JRE/JDK.
For a given Eclipse project:
right click on the project, select Properties -> Java Compiler, override and set compiliance level settings.
Check Use compliance from ..., visit the Java Build Path and be sure you have a JRE Library set that matches the desired compliance level.
For a given Eclipse Run Configuration: Run -> Run Configurations... -> Java Application, select an old or create a new configuration, select the JRE tab and specify the Runtime JRE.

Setting JRE in Netbeans

I have JDK 1.6, JRE6 and JRE7 (64-bit & 32-bit) installed in my PC.
I am using Netbeans 7.3 BETA 2 and it is using JDK 6 and JRE 6.
I want to change it to JRE7. How can i achieve this ?
I have checked in Stackoverflow itself and found that we have to change the netbeans.conf file content for the netbeans_jdkhome value to the path of new Java path.
In another stackoverflow question, I found How to specify which JRE to use in Netbeans?.
But, in this also, I am not able to find how to get this resolved. Can anybody help on this ?
My installation path is as follows,
JDK6 path - C:\Program Files (x86)\Java\jdk1.6.0_31
JRE6 path - C:\Program Files (x86)\Java\jre6
JRE7 path - C:\Program Files (x86)\Java\jre7 (32-bit)
JRE7 path - C:\Program Files\Java\jre7 (64-bit)
Thanks in advance.
Goto Tools -> Platforms
Click "Add Platform", browse to the location where the JDK you want to add is installed....
Click on the JDK you want to add and select "Finish"
Updating projects
You can change the platform that projects use, by right clicking the project node and selecting properties and selecting Libraries. Here you change the platform that the project will use to build the classes with.
You can also change the source/binary format (version) which Netbeans is expecting to use. For example, you use JDK 7, but build/develop for Java 6
Changing the JDK that Netbeans itself uses to run
Goto {install/location/of/Netbeans}/etc and open the netbeans.conf.
There is a property called netbeans_jdkhome (it was towards the end of my file). You change this to what ever JDK you want Netbeans to be launched with

how to install jdk 7 in eclipse

I downloaded and installed jdk7 on my mac and wanted to find out the actual content of it so that I can install it in eclipse. There is no jdk 7 related content in /System/Library/Java.
You need to let know eclipse where the JRE 7 is, and you can do in this way :
Go to Preferences pane of eclipse
Open Java on the left pane
Click on Installed JREs
Add Button ---> Standard JVM and Next
Insert : /Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk/Contents/Home in the JRE Home TextBox
Next and Save the configuration
You need to add JDK 7 to the list of installed JREs in Windows-> preferences -> java -> installed JREs.
It is located in /Library/Java/JavaVirtualMachines/...
So in /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home you can find the bin folder, lib folder etc.

Point eclipse IDE to use another JRE / JDK other than one specified in JAVA_HOME

I am having two JRE / SDK in my development environment, however it was necessary in my situation to set JAVA_HOME to 1.4.2, this is causing my eclipse IDE to stop running as it required 1.6 and above.
May i know how i can modify eclipse ini or environment home to use my other 1.6 installation?
Please try the eclipse.ini entry above the varargs (the following two lines must be two lines in the eclipse.ini file)
-vm
C:\Java\JDK\1.5\bin\javaw.exe
Find the JVM
Right click the project in Package Explorer -> Configure Build Path
Add Library -> JRE System Library
Set JRE system library to JDK
Verify JDK is the reference library
From the menu in the top.. Proceed as follows--
Project-->Properties--> Java Build Path--> Libraries--> JRE System Library.
Now click Edit . Select Alternate JRE. Click Installed JRE. Provide path to your other JDK. Then FINISH.
That's it.