Results 1 to 10 of 10

Thread: STS with Gradle - Java_HOME not found

  1. #1

    Default STS with Gradle - Java_HOME not found

    Hello There,

    I tried the gradle-sts documentation .
    http://static.springsource.org/sts/d...-tutorial.html

    When I am building Gradle I get :

    Code:
    Cause: Unable to find a javac compiler;
    com.sun.tools.javac.Main is not on the classpath.
    Perhaps JAVA_HOME does not point to the JDK.
    It is currently set to "C:\Program Files\Java\jre6"
    Now I am using all default Gradle option so not sure what going wrong.


    My STS version is 2.9.1

    Thanks

  2. #2
    Join Date
    May 2010
    Posts
    398

    Default

    This could be either one of two problems:
    1) you have only a JRE installed on your system. Gradle needs a JDK (JRE doesn't have the javac compiler, which gradle needs).
    2) you have both a JRE and a JDK installed, but gradle doesn't find the JDK because it only looks in the 'standard' location where it just finds the JRE.

    Depending on what you have installed on your system you may be able to decide which of the two cases you are in.

    If you are in case 1) you will need to install a JDK. (Then you might end up in case 2)

    If you are in case 2) please take a look at this issue:
    https://issuetracker.springsource.com/browse/STS-2276

    In short, only recently has it become possible to tell Gradle from within STS which JAVA_HOME to use. You will need to install a nightly snapshot of the gradle-sts tools to get this option. Or you can try some of the workarounds suggested in the issue.

    Kris
    Kris De Volder -- SpringSource

  3. #3

    Default

    Hey Kris,

    I have JDK installed in seperate location :

    Java - SpringSource Tool Suite_2012-04-13_08-35-07.jpgJava - SpringSource Tool Suite_2012-04-13_09-56-31.jpg

    I am not able to set JVM_OPTION from gradle preference page as bug 2276 suggests.

    Please suggest.

    Thanks
    Priyanka

  4. #4

    Default

    Ok , I updated the STS Gradle with nightly build plugin I see java _home option. When I select it and give workspace jre ,it takes that. But gradle build still fails with java_home error . When I go back to to preference page . I see in java home section of Gradle preference it show -use gradle wrapper's default . Why it is not remembering the option.


    new.jpg

  5. #5
    Join Date
    May 2010
    Posts
    398

    Default

    Hi Priyanka,

    I don't know why it is not remembering the option. It could be a bug. This preference page is really brand new and I bet that you are one of the first few people to actually use it. So if it was a bug in my implementation, I wouldn't be too surprised.

    Could you be more precise on what you did? I just tried to set the option. Click 'Apply' button. Then close the prefs dialog. When I reopen it it is still set.

    I also then closed my STS and reopened it (to verify if perhaps the settings where not actually persisted on disk between sessions). But that also seems to work for me.

    But maybe there is some sequence of steps where the prefs are not properly saved. Or maybe this could be a Windows <-> Linux bug. Or perhaps you accidentally clicked 'Cancel' instead of 'Apply'.

    Kris
    Kris De Volder -- SpringSource

  6. #6
    Join Date
    May 2010
    Posts
    398

    Default

    I played with it a bit more and found a potential problem with the UI. Maybe that is what happened for you.

    When I type some text in the combo box after selecting the JRE. E.g. add a couple of extra spaces at the end of the workspace JRE name...

    Then close and reopen the prefs page... Then it will be reset to 'use gradle wrapper's default'. This is because the selected name with the extra text added no longer corresponds to a valid JRE name.

    This shows I really should add some validation logic to the UI to prevent this from happening (or at least have some error message when an invalid name is present in the combo box.

    Kris
    Kris De Volder -- SpringSource

  7. #7

    Default

    OK Here are set of steps :-

    Gradle Preferences -> Java Home select Workspace JRE :
    hit Appy than OK

    Go to build.gradle ->Run As Gradle Build ... ->Run

    Error comes back->
    Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
    Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.0-rc-1-bin.zip'.

    Again go back to Gradle preference -> See Java Home the check box of use Gradle wrapper's default is selected .

    It is not remembering the option.

  8. #8
    Join Date
    May 2010
    Posts
    398

    Default

    The steps you did should work. If they don't, this is a bug. Unfortunately, when I do the same steps it does work for me.
    Also I had at least one Windows user confirm to me that it worked for them. So this makes it all the more puzzling.

    I don't know what we can do to figure out why its not working for you.

    I did however already patch up the UI a little and fixed (https://issuetracker.springsource.com/browse/STS-2556).

    It should be already on the nightly update site. It may be useful if you could update to this latest version. It can't really promise it will help, but I'm not sure what else to try at the moment. While you try that, I'll give it some more thought.

    Kris

    PS: Does the name of the JRE or its path contain any special or funny characters (often when something hits a particular user only, it is because of something like that triggering a bug that others are not hitting, so its worth checking).
    Kris De Volder -- SpringSource

  9. #9

    Default

    Hey Kris,

    I got the latest nightly build and now it is remembering the jre preferences. Also I am able to the gradle build.

    Thanks
    Priyanka

  10. #10
    Join Date
    May 2010
    Posts
    398

    Default

    Glad to hear it! Thanks for letting me know.

    Kris
    Kris De Volder -- SpringSource

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •