Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-4722

JAVA_HOME not set on Gradle projects.

    XMLWordPrintableJSON

Details

    Description

      On a new empty "Java with Gradle" project, when running with `run`:

      public static void main(String[] args) {
          System.out.println("ENV1: " + System.getenv("JAVA_HOME"));
          System.out.println("ENV2: " + System.getenv("_"));
      }
      

      the result in the Output window is:

      JAVA_HOME="/Users/$user/Downloads/jdk-11.0.2.jdk/Contents/Home"
      cd /Users/$user/NetBeansProjects/gradleproject; ./gradlew --configure-on-demand -x check run
      Configuration on demand is an incubating feature.
      > Task :compileJava
      > Task :processResources NO-SOURCE
      > Task :classes
      
      > Task :run
      ENV1: null
      ENV2: /Users/$user/Downloads/jdk-11.0.2.jdk/Contents/Home/bin/java
      

      So internally JAVA_HOME is set for NetBeans, but the project doesn't have access to it.

      This might be a bug, as there is an environment variable named `_` that has the value expected for `JAVA_HOME`.

      On a Maven project, `JAVA_HOME` is printed with the correct value, but `_` doesn't exist (as expected). This result is the also the expected for both Maven and Gradle projects on Windows.

      Attachments

        Issue Links

          Activity

            People

              lkishalmi Laszlo Kishalmi
              jpereda José Pereda
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h