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 9040581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:01:22+00:00 2026-06-16T10:01:22+00:00

I am able to run a Linux command via RunTime class. Is there a

  • 0

I am able to run a Linux command via RunTime class.
Is there a way of setting a Linux global enviroment from Java programatically?

I want to emulate the following Linux command statement over Java

root@machine:/tmp# export TEST=v2

I have used ProcessBuilder as following, but TEST variable does not changed.

ProcessBuilder pb = new ProcessBuilder("/bin/bash","-c","export TEST=v3" + "&& exec");

UPDATE:
Actually my ultimate target is to use EMAIL_NAME enviroment as an email address, when both my application and machine are started and stopeed these actions will be sent to EMAIL_NAME.
In that case I understand that it is not possible to set linux global enviroment over pure Java code. So I have a workaround solution is that EMAIL_NAME will be hold in a file and it will be updated or read by linux script or java code.

  • 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-16T10:01:24+00:00Added an answer on June 16, 2026 at 10:01 am

    Environment variables, when set, are only available to processes spawned by the process where the variable is set, so if you’re really asking to set a variable that will affect the entire system, then no. You can’t really do that at all in Linux interactively. The best you could do is alter one of the system startup files to include said variable so that anything you do in the future would include that variable.

    If you’re simply looking to run several processes with some variable set, then ProcessBuilder allows you to set an environment for processes spawned with it. Reusing an environment for several processes is pretty trivial with that.

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

Sidebar

Related Questions

I want to be able to run Junit tests from the command line, but
On osx/linux I want to be able to run a command on the terminal
Possible Duplicate: php shell_exec() vs exec() How do I run a linux command from
I'd like to be able to run a command that opens up a git
I can run an svn command from the command line but not from within
I have written an application that is able to write posts from the command
:) I'm wanting to be able to run a system command when an IPTable
I'm trying to run a scheduled cron job using a crontab from a linux
I am trying to run some Java code I found on linux. maudecmd =
I have been able to run my C# .net 3.5 app just fine on

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.