Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:21:17+00:00 2026-06-08T20:21:17+00:00

In my Groovy script I have this code: def username = System.getenv()[‘USER’] def password

  • 0

In my Groovy script I have this code:

def username = System.getenv()['USER']
def password = System.getenv()['PASS']

It is because I can’t use this information as parameter to Groovy script, because other users shouldn’t know it. When I run this script I set this parameter in my system. Now I have a problem. I have a Java application which runs Groovy script remotely. Is there some way that I can set enviromental variable in Java code? (Here I found that it isn’t possible). Or is there some safe ways to send this properties from Java to Groovy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:21:19+00:00Added an answer on June 8, 2026 at 8:21 pm

    If you’re launching the groovy script by the lowest common denominator of Runtime.exec (or similar), then you can specify the environment in one of the overloaded methods:

    Executes the specified string command in a separate process with the specified environment.

    …

    envp – array of strings, each element of which has environment variable settings in the format name=value, or null if the subprocess should inherit the environment of the current process.

    If on the other hand you’re invoking the Groovy script within the same Java process, then it will have the same properties as the running process. So simply calling System.setProperty("USER", xxx) before invoking the Groovy script will mean this property is visible to your Groovy logic.


    You should note that the environment is an operating-system level thing; a measure of the properties of the OS on which the process is running.

    If you’re looking for application-level settings, you really ought to be checking System.properties instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some groovy code like this: def dest = destSql.dataSet('destination_table') sourceSql.eachRow('select * from
In Groovy Console I have this: import groovy.util.* import org.codehaus.groovy.runtime.* def gse = new
I have sample code as below import org.codehaus.groovy.control.CompilerConfiguration abstract class MyClass extends Script {
We have a chunk of code something like this // semi-pseudo code def result
I have the following Groovy code: abstract class Actor extends Script { synchronized void
I have a simple groovy script that generates xml def builder = new groovy.xml.StreamingMarkupBuilder()
I'm writing a Groovy script which uses third party java code that I can't
I am trying to connect a simple groovy script to the DB. Code: import
I wanted to use groovy for a little ftp script and found this post
I have one groovy script which print some statistics: println: ... now I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.