IntelliJ IDEA 2016 project change java sdk version from 7 to 8 - java

The external libraries in Project window shows that the project was using jdk7.
Then I change the jdk version in File > Other settings > Default project structure> SDKs, by adding jdk 8 from its installed location. Now java 7 is gone, but java 8 does not show up and it could not compile. Is this a bug or did I miss anything?
if I add java 7 then it comes back in External Libraries:

You also have to adjust dependencies in module itself / remove old 1.7 libraries and add from new sdk

change the module settings indeed. Right click on the module (which I understand it as project in Eclipse I guess) and click Open module settings (F4 shortcut), and on tab dependencies, change it to 1.8, originally it was blank. (If it was blank shouldn't it be using the project settings which is already configured as java 8, but no, for some reason it still use java 7)

Related

How can i use eclipse 2020-09 to develop java 8 projects?

I am a regular IntelliJ user, but most of my co-workers use Eclipse. A lot of them say the latest version of Eclipse "2020-09", which requires a JRE "higher than Java 8" in order to run, cannot be used to develop projects requiring JRE8.
This is pretty surprising to me, since I know it is possible to install multiple JDKs and JREs on one machine, I've done it plenty of times.
What is the typical way a person would configure Eclipse 2020-09 (already installed) to work on a project that requires a Java 8 JRE?
JRE 8 apps in eclipse workspace is possible by having the jre 8 jdk. It is true that in order to use eclipse 2020-09 you need java 11+ jdk/jre, but making projects that support jre 8 is still possible.Even I still use 2020-06 and before. Here is a method you could use to get JRE 8 implemented back in your project. Although you can change the defaults, this one will help you change the environment back to java 8 for 1 project.
Right click the library named somthing like "JRE system library[JavaSE-11]". Press properties. This is what you will see JRE System Library chooser image
Choose "Alternate JRE" then click "Installed JREs"Step Image
Press "Add" then you will see 3 options. Choose standard VM. Find your java 8 jdk directory. Usually it is something like C:\Program Files\Java\jdk1.8.0_251.
You can configure the default arguments for your jvm runtime. Then simply hit ok,select the jdk-8 library and close it. Then choose alternate jre again and in the drop-down choose jdk-1.8.0 or some name like that. This will only work if you also have java 8 installed alongside java 11 that is configured properly JDK
You can use Java 11 to start the Eclipse 2020-09 and configure a project to compile with Java 8. The problem is if you want a Eclipse plugin that uses CORBA for example. This module was removed from Java 11 earlier. In this case, I recommend to use Eclipse 2020-06.
Earlier versions of 2020-09 was working with Java 8. I had it, too. Then I updated and I got the same error message like you.
I propose to use an older one or to install JRE 11 and set the JAVA_HOME env variable to it.
The inside the IDE you can set java 8 like an JDK and develope your project with Java 8 while eclipse is running with 11.

Idea says "The JavaFX runtime is not configured. Either use a JDK that has the JavaFX built in, or add a JavaFX library to the classpath"

I recently installed Java 10. The JavaFX project I opened runs with Java 8, and its "Project SDK" and "Project language level" in Idea are both set to use JDK 8, and Java 8 includes the jfxrt.jar file where it's supposed to be (jre/lib/ext). I can build and run the project on the command line with Gradle without issue.
If I modify how Idea starts up to use Java 8, Idea doesn't complain.
So... is this a bug? I'm not up on the new dependency tree stuff, but shouldn't Idea declare JavaFX as a dependency if it needs it? Clearly the project I'm working on is set up fine.
You can follow the steps on the openjfx website to add JavaFX to IntelliJ (look under the JavaFX and IntelliJ section on the left-hand menu).
Install JavaFX from here
Navigate to File -> Project Settings
Install SDK 19
On the Libraries tab, add the JavaFX 19 SDK as a library to the project

JRE version is 1.6.0; version 1.7.0 or later is needed to run Google Plugin for Eclipse

I have 3 versions of Java installed on my system: 6, 7, and 8... I am required to have JRE6 available for a product my company develops, so I cannot get rid of it... But despite copying my Eclipse install to a new folder for another project I need to work on and removing JRE6 from this version alltogether, I still cannot get it to work.
How can I get the google plugin for Eclipse to work in my scenario?
If you have created a shortcut to start eclipse, you can add a parameter to tell it to use the jre of your choice like this -
C:\eclipse\eclipse.exe -vm "C:\Programs\jdk\jdk1.7.0_55\bin\javaw.exe"
I have used "javaw" executable from a jdk installation, but you may point to the same executable within a JRE installation as well.
This will resolve the error.
Keep in mind that there is a separation between the JVM that Eclipse itself is running in and the various JREs that you can configure in Eclipse to run your programs/applications. You need to specify to Eclipse what JVM you want it to run under, using eclipse.ini.
That's separate from the Installed JREs configuration you show in your screen shot above.
Add Java 7.0 to Eclipse if you haven't: Window -> Preferences -> Java -> Installed JREs.
Next add Java 7.0 library to your project: Right click on project -> Properties -> Java Build Path -> Libraries tab -> Remove JRE 1.6 and add New Library (JRE System Library, 1.7.0).
Last set Java 7.0 compliance level: Right click on project -> Preferences -> Java Compiler -> Compiler compliance level: 1.7
Also since you can use different Java to run applications, you also have to change this in the Run configuration which you use to start AppEngine related tasks.

How to add and use all the different JDK versions in netbean?

I am using windows 7 64, IDE netbeans 8. I have got some projects compiled in different jdk versions jdk 6, jdk 7 and jdk 8, manytimes I face the error of major.minor, to avoid it I am changing the jdk according to need, but it consumes a lot of time to install and uninstall jdks again and again. Is there any easy way to add and use all the jdks in the netbeans by switching etc.?
If you have a project open, you can go to file -> project properties. At the bottom of the window you'll find a menu labeled source/binary format. You should be able to select the jdk version there.
I am not sure if you are using ant/maven/gradle to build your project with, but you can specify the source and target compatibility for each specific project.
maven -> http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
ant -> http://ant.apache.org/manual/index.html
gradle -> http://www.gradle.org/docs/current/userguide/java_plugin.html#N1223E
See FaqJdkHome and How to set and use different JDK versions in NetBeans.

How to change JDK version for an Eclipse project

I need to write a project that's only compatible with Java 1.5. I have Java 1.6 installed. Is there some form of backwards compatibility to get Eclipse to compile with 1.5?
Do I have to install Java 1.5 to get it to show here? Or maybe there is another way?
.
Click on the Add Library button. It brings your screen to point to the Java location.
Select "Directory", button right besides JRE home and point to the installed folder location.
Even though you want to just 1.5 compiler project, you can achieve it by changing compiler settings in Eclipse instead of removing 1.6 JRE and add 1.5 JRE.
GOTO -->JAVA--Compiler---> and change compiler level to `1.5` instead of `1.6`
As davidfmatheson suggested,
Just be careful, especially if you're setting this up for a team of people to work on. If anyone uses anything that is new or changed in 1.6, it will compile, but not run in an environment with JRE 1.5.
Click on the Window tab in Eclipse, go to Preferences and when that window comes up, go to Java → Installed JREs → Execution Environment and choose JavaSE-1.5. You then have to go to Compiler and set the Compiler compliance level.
Right click project -> Properties -> Java Build Path -> select JRE System Library click Edit and select JDK or JRE after then click Java Compiler and select Compiler compliance level to 1.8
If you are using maven build tool then add the below properties to it and doing a maven update will solve the problem
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
In the preferences section under Java -> Installed JREs click the Add button and navigate to the 1.5 JDK home folder. Then check that one in the list and it will become the default for all projects:
Eclipse - specific Project change JDK Version -
If you want to change any jdk version of A specific project than you have to click ---> Project --> JRE System Library --> Properties ---> Inside Classpath Container (JRE System Library) change the Execution Environment to which ever version you want e.g. 1.7 or 1.8.
The JDK (JAVA_HOME) used to launch Eclipse is not necessarily the one used to compiled your project.
To see what JRE you can select for your project, check the preferences:
General → Java Installed JRE
By default, if you have not added any JRE, the only one declared will be the one used to launched Eclipse (which can be defined in your eclipse.ini).
You can add any other JRE you want, including one compatible with your project.
After that, you will need to check in your project properties (or in the general preferences) what JRE is used, with what compliance level:
(source: standartux.fr)
See the page Set Up JDK in Eclipse. From the add button you can add a different version of the JDK...
As I was facing this issue minutes ago, in case you are trying to open an existing project in an environment with a newer JDK, make sure you pdate the JDK version in Project Properties -> Project Facets -> Java.

Categories