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.
Related
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.
I had java version 8 previous and my eclipse worked just fine. But now I have java version 7 and I can't open eclipse on my computer. What should I do? please help.
I think there are two options:
Upgrade to Java version 8 (or newer).
If you can't do that, downgrade to a version of eclipse that supports Java 7. eclipse 4.5 (Mars) (or earlier as noted on the linked page), as of eclipse 4.6 (Neon) Java 8 is required.
I feel I should note that newer versions of Java (and eclipse) can still target Java 7 (and many earlier versions).
But now I have java version 7 and I can't open eclipse on my computer. What should I do?
Use versions that work together. When you for example look at your second screen shot, it says something like "requiredJavaVersion=1.8" or so.
In other words: you can't just come in and run eclipse with any version of java.
The other answer gives you the required details.
And a final note here: in case you tried to start eclipse with that older JVM in order to "allow" to ensure that eclipse won't allow "java 8" stuff in a project: that isn't the right way then. Instead: eclipse allows you to "define" JDKs to be used for your project. So you can easily tell eclipse: "I have a Java7 jdk sitting here, please use that for project X".
You do not need to run eclipse itself with a Java7 JVM in order to use a Java7 JDK for an eclipse project!
There will be a file under the Eclipse installation directory named as eclipse.ini.
It will launch the eclipse for that specific jdf and you can change the path to your jdk7.
Hope it helps.
It depends basically on which version of the eclipse you have.
If you have eclipse 4.6(Neon) or the latest version, then you must need a newer JDK version of Java (>=1.8 which you need to download). Or If you want to roll back to an older version of Eclipse then consider downloading eclipse 4.5(Mars).
Or If you have an eclipse version of 4.5(Mars) or older then see in eclipse.ini
-Dosgi.requiredJavaVersion = 1.8 and change it to -Dosgi.requiredJavaVersion = 1.7 which can be found in the folder containing eclipse.exe file.
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)
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.
I primarily use JDeveloper 10 with JDK 1.4.2 on Vista. I would like to install Eclipse and have it run the latest JDK 6.
Is this possible without conflict?
Ideally I would like to just use JDeveloper and switch back/forth between JDK versions. Is this possible?
It is indeed possible, you can have as many JDKs in system as you wish.
Just install them into different directories, then you can add a new JDK to your IDE (they support having multiple).
You can choose one on per-project basis.
I am not sure with JDeveloper 10, but in eclipse you can specify which installed JDK you wish you use under window>preferences>Java>Installed JREs.
You can specify the JRE for Eclipse to run under with the -vm command line switch or in eclipse.ini. e.g. -vm "%JAVA_HOME%/bin/javaw.exe"
You can specify the JRE for executed code via the Window:Preferences:Java:Installed JREs menu.
If you select project properties in Eclipse, then Java Build Path, you can choose a different JDK to use when building the project.