I am using Jenkings on Cloudbees and I would like to change the JDK version to 1.8.
I followed the tutorial at developer.cloudbees.com/bin/view/DEV/PreInsatlledJDKs. However, I fail at step 10 -> There is no such option to choose the JDK. Where can I change this?
UPDATE: I made some screenshots to better explain my problem.
This is the jenkins configuration for the JDK. As you can see, I only have one JDK selected and it's Java 8.
However, if I view my "System Information", everything looks like Java 7. It says that "java.home" still points to "/opt/java7/jre" and "java.runtime.version" points to "1.7.0_25-b15" for example.
Not surprisingly, the compilation process of my maven project fails, because for the maven compiler plugin I specified 1.8 as source and target java version.
If you have one single JDK, then you won't see that option, cause it will pick it up by default.
You will se the JDK option with the drop down menu if you have more than 1 JDK configured in your jenkinsURL/configure.
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.
Can you define anywhere in your Java Project which JRE/JDK version should it pick up?
In eclipse when I choose the project >> right click >> Java Compiler and check the "Compiler compliance level" I see a certain version marked (1.7,1.6 etc). How is this chosen?
Or is this entirely just dependent on what JDK/JRE runtime version your server (tomcat) is using?
Thanks
Short answer:
No, you can not identify the version of java that will be "picked up" at runtime.
More of an Answer:
There are three Java versions that come into play when building and running something using Java.
The source version. This is the version of Java to which the source of the project complies. When compiling, you can pass a "source" (try google search for "set java source level") parameter to identify this version. In practice, I don't know the value of this.
The target version. This is the version of Java to which the compiled result will comply. As with "source version" you can pass this as a parameter to the compiler.
Runtime version. This is the version of java that is actually installed on the host that is running the compiled java (the byte codes). You can never configure this at compile time since this is the thing that is installed on the runtime host.
There are some caveats.
The source and target version numbers must be equal to or less than the version of the java compiler that is actually compiling the java source. For example, you can choose target version 1.7 if you are compiling using a version 1.8 java compiler. You may not choose target version 1.8 if you are compiling using version a 1.7 java compiler.
It is possible to install multiple versions of java on a host. It is not possible to choose which version of java tomcat will use to execute your application since the version of java that will be used by tomcat is the version of java that is running tomcat.
It is chosen in that drop down menu, you can set it to whatever you'd like. However, you must have that version installed on your system/server in order for the project to function correctly. If you go to Window->Preferences->Java->Installed JREs, you can see which JREs you have installed. When you create a new server element in eclipse, you can also set the JRE of the runtime, and just make sure it matches the version of your project.
How can I change the Projects Runtime Platform?
(standard NetBeans [8.1] Java Project [Java Application])
Details:
using Ubuntu with NetBeans 8.1
I have installed JDK 1.6, JDK 1.7 + JDK 1.8
My projects platform is Java 6.
My systems default Java is Java 7.
NetBeans-IDE was started with Java 8.
When I run the project via the IDE (Run project), the Project-Platform is used (which is Java 6).
I cannot change the Runtime Platform!
It's always: Project Platform
I tried to Manage Platforms..., but I still can't change the value of the Runtime Platform-ComboBox.
EDIT:
As I wrote in the comments, I don't want to change the Project-Platform.
The project should be compiled with Java 6 but run with Java 8 (when click on Run project).
What I want is:
Project-Platform = Java 6 (used to compile),
Runtime-Platform = Java 8 (used to run).
How can I change the Projects Runtime Platform?
Unfortunately you can't. As you point out, its value can only be Project Platform. Of course that invites the question "What is the point of even having that Runtime Platform field?".
I suspect that it may have been (unwisely) added to the GUI so that at some time in the future it will be possible to actually select a different JDK to run against. There is an open Bug Report for this: Bug 186747 - Can't Build and Run with Different Java Versions.
It's also worth noting that the Help documentation for the Run screen does not mention that Runtime Platform field. My own view is that the field should be removed until it serves a useful purpose.
What I want is: Project-Platform = Java 6 (used to compile),
Runtime-Platform = Java 8 (used to run).
Unfortunately that can't be done, as shown by the open bug. The best you can do right now is:
Create platforms for JDK 6 and JDK 8 in NetBeans.
Set the Java Platform to JDK 1.6 on the Libraries screen, and set the Source/Binary Format to JDK 6 on the Sources screen, then build to verify that no invalid APIs are being used.
Switch the Java Platform to 1.8 on the Libraries screen to run your 1.6 code under 1.8.
I realize that you don't want to do that, but unfortunately there's no silver bullet in the current release of NetBeans (8.2).
An alternative approach would be to build and run using only JDK 8, but include the Animal Sniffer Maven plugin "for checking projects against the signatures of an API", to verify that your 1.6 code was not using illegal APIs. But of course that's only viable for Maven projects.
Please look at Netbeans Project Setup - Setting the Target JDK in a Project
You just have to change the Runtime Platform at the Libraries option, that's all.
Just went through this pain for Apache NetBeans 14. I was trying to set a remote debug for a Raspberry Pi.
It works only if the jdk match on both the local and remote versions. In my case I set them both to 17.
I would have expected that the default jdk on the local machine should have been able to be changed but I fail to determine how.
I am running Ubuntu on the local machine so maybe the platform cannot be changed (don't know). Moving on.
Changed runtime platform
switch(title)
{
case "Return":
returnBooks();
break;
}
strings in switch are not supported in -source 1.6, use -source 7 or higher to enable strings in switch
So, I have already installed JDK7, Why compiler show this message and giving an error while on compiling?
I am using NetBeans
I hate to say it, but: read the darn error message. It tells you exactly what the problem is.
You are compiling in Java 6 mode, not compiling in Java 7 mode. If you're using javac that comes with JDK 7, as the error message says, use the -source 7 flag:
> javac -source 7 {stuff here}
Two key points from the user query:
Already installed JDK7;and
Using Netbeans
So, netbeans came with two package:
With JDK
Means when install the Netbeans 7 it automatically install JDK 7 and set JDK 7 as Default Library.
Without JDK
On the installation of NetBeans 7, it found JDK in the system, and if found it automatically configure the path of library as well, but show you information about the path and version of JDK7.
All of users try to give the correct answer of this query, but no one is in position to answer in the correct way as the user required because user using the Netbeans as well.
With continue the edit version of Hemal Pandya, one thing more is required to configure, which is that
RightClick on Project > properties > and in the categories option select > source. see the
**Hemal Pandya** edit version to look at image, the source option is available above the
Libraries option.
And
then select **Source/Binary Format** form bottom and set it to JDK 7 (= 1.7). this is the exact solution
of user's post and I am 100% sure now String in swich will work
In NetBeans, go to the properties of the project and change the java platform to java 7 in libraries
I have found a solution:
If you are using Netbeans 7.1 (even, 7.0), just you have to follow this:
Right Click on Project -> Properties -> Sources -> (On the bottom) Source/Binary Format
Just select JDK 7, and that's all, you can then use strings in switch!
I do not use NetBeans but there seems to be a compliance switch that has defaulted to 1.6. You will have to find that switch and set it to 7, as others have pointed out.
EDIT: I found I found netbeans.org/kb/docs/java/project-setup.html#projects-jdk. You seem to have done the second step of registering jdk. But maybe it is not the default? Follow the instructions to To switch the target JDK of a standard project. Looking at images it seems to be in this dialog: