[GRADLE-2386] System.console() returns null when used in conjunction with org.gradle.java.home property Created: 13/Jul/12  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Won't Fix Votes: 3


I'm trying to use the System.console() from within my gradle script. All seems to be working fine EXCEPT when I am using the org.gradle.java.home property. If I have that set to switch to a different jvm then I get null as a return from System.console().

The reason I need to switch jvms is because I'm on a 64-bit machine. One of my tasks interacts with the Starteam ant tasks, which basically farms out the work as a native library to the Starteam client. The Starteam client libraries are only 32-bit, so when I need to run those specific tasks I use the org.gradle.java.home property to switch to a 32-bit jdk. When I do this System.console() also stops working.

I even tried ant's input task, which does still seem to work, except for the SecureInputHandler (I am reading a username & password). When I use ant's input task the password still echos to the screen.

Is there a workaround for this?

Comment by Gradle Forums [ 13/Jul/12 ]

Are you using the Gradle daemon? If not, can you enable it and check if it makes a difference?

Comment by Gradle Forums [ 13/Jul/12 ]

Doesn't seem to make a difference. I still get "Cannot invoke method readLine() on null object" when trying to do System.console().readLine() or System.console().readPassword().

If I remove the line org.gradle.java.home from my gradle.properties the System.console() works (but then my starteam ant tasks don't because of the fact the default runtime jvm on my machine (& on our CI servers) is 64-bit.

Comment by Gradle Forums [ 13/Jul/12 ]

Might be a bug then. I'll raise an issue.

Comment by Santoash Cuddalore Rajaram [ 16/Feb/14 ]

This is not specific org.gradle.java.home property. This happens to me anytime I have a gradle.properties in my project directory with org.gradle.jvmargs property set.

Comment by Santoash Cuddalore Rajaram [ 16/Feb/14 ]

Also, This seems like a dupe of http://issues.gradle.org/browse/GRADLE-2310

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 12:20:29 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.