Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-4437

Should be able to select project JDK when only one JDK entered in hudson config

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • core
    • None
    • Platform: All, OS: All

      Hi

      The default java on my system is 1.5, but I've also got 1.6 installed.

      The maven project I was building required the use of the 1.6 JDK. The path to
      my JDK 1.6 can be entered on the hudson 'configure system' screen, but it isn't
      possible to choose this JDK in the project config (and if you don't specify a
      JDK here the default system JDK gets used). I eventually discovered that the
      option to choose JDK only appears if two or more JDKs are entered in 'configure
      system'
      It should be possible to override the default JDK without having to specify more
      than one JDK.

      Kind Regards,
      Alex

          [JENKINS-4437] Should be able to select project JDK when only one JDK entered in hudson config

          Alan Harder added a comment -

          I looked at the code and it appears the intention is to always use the
          configured JDK when there is only one (never use "(Default)", ie java from
          path). If you had no JDKs and added one this would work correctly; all projects
          would then use the configured JDK. However, if you have multiple JDKs and some
          were configured with "(Default)", then moving down to one JDK does not switch
          those projects. They continue to use java from path until you click Save on
          their config screen, which will switch it over (even though no JDK selector
          appears).

          So the question is: show the selection box when only one JDK is configured (pick
          "(Default)" vs that one) or fix things so moving down to one JDK switches all
          "(Default)" projects to that one JDK.

          Alan Harder added a comment - I looked at the code and it appears the intention is to always use the configured JDK when there is only one (never use "(Default)", ie java from path). If you had no JDKs and added one this would work correctly; all projects would then use the configured JDK. However, if you have multiple JDKs and some were configured with "(Default)", then moving down to one JDK does not switch those projects. They continue to use java from path until you click Save on their config screen, which will switch it over (even though no JDK selector appears). So the question is: show the selection box when only one JDK is configured (pick "(Default)" vs that one) or fix things so moving down to one JDK switches all "(Default)" projects to that one JDK.

          gbonk added a comment -

          Finding this helped me to fix my issue that I was having when I upgraded to 1.339 . I also have JAVA_HOME=C:\Program Files\Java\jdk1.6.0_17 . My Hudson instance is running inside of Tomcat which I also have pointed to a JDK.

          My console output would show...

          Operation completed
          [.] $ java -Xmx1024m -cp
          

          Would result in this error...

          [INFO] Compilation failure
          Unable to locate the Javac Compiler in:
            C:\Program Files\Java\jre6\..\lib\tools.jar
          Please ensure you are using JDK 1.4 or above and
          not a JRE (the com.sun.tools.javac.Main class is required).
          In most cases you can change the location of your Java
          installation by setting the JAVA_HOME environment variable.
          

          I added any other JDK to the Hudson configuration then I went to each project and was able to set the project to the correct JDK. Now my output is like this...

          Operation completed
          [.] $ "C:\Program Files\Java\jdk1.6.0_17/bin/java" -Xmx1024m -cp
          

          I sure would like this to be cleaned up and streamlined. I didn't see any detailed explanation on the WIKI and I don't understand the mechanism that Hudson uses well enough to create a new page.

          gbonk added a comment - Finding this helped me to fix my issue that I was having when I upgraded to 1.339 . I also have JAVA_HOME=C:\Program Files\Java\jdk1.6.0_17 . My Hudson instance is running inside of Tomcat which I also have pointed to a JDK. My console output would show... Operation completed [.] $ java -Xmx1024m -cp Would result in this error... [INFO] Compilation failure Unable to locate the Javac Compiler in: C:\Program Files\Java\jre6\..\lib\tools.jar Please ensure you are using JDK 1.4 or above and not a JRE (the com.sun.tools.javac.Main class is required). In most cases you can change the location of your Java installation by setting the JAVA_HOME environment variable. I added any other JDK to the Hudson configuration then I went to each project and was able to set the project to the correct JDK. Now my output is like this... Operation completed [.] $ "C:\Program Files\Java\jdk1.6.0_17/bin/java" -Xmx1024m -cp I sure would like this to be cleaned up and streamlined. I didn't see any detailed explanation on the WIKI and I don't understand the mechanism that Hudson uses well enough to create a new page.

          Daniel Beck added a comment -

          Reference: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/Jenkins.java#L1630

          While this behavior seems weird, it will not result in the problem described in the issue description: If the system default is 1.5, and you configure only one JDK in Jenkins and that is 1.6, Jenkins will use 1.6 for all projects.

          Daniel Beck added a comment - Reference: https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/jenkins/model/Jenkins.java#L1630 While this behavior seems weird, it will not result in the problem described in the issue description: If the system default is 1.5, and you configure only one JDK in Jenkins and that is 1.6, Jenkins will use 1.6 for all projects.

          Daniel Beck added a comment -

          Daniel Beck added a comment - Introduced here for JENKINS-659 : https://github.com/jenkinsci/jenkins/commit/4b831e56c09e673cbb8df2b782d42a951dc8a738

            Unassigned Unassigned
            alexjfisher alexjfisher
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: