Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #23964
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Setting a property for System.getProperty() |
| Date | Thu, 09 May 2013 11:33:23 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 36 |
| Message-ID | <kmgfd9$p13$1@dont-email.me> (permalink) |
| References | <38d76348-f691-439f-b476-50eeb2908c14@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Date | Thu, 9 May 2013 15:29:45 +0000 (UTC) |
| Injection-Info | mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="25635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186huf02gsFhro9HQcZl356" |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 |
| In-Reply-To | <38d76348-f691-439f-b476-50eeb2908c14@googlegroups.com> |
| Cancel-Lock | sha1:b+XZSbn84gJzxpnnPRGWLEhaHHk= |
| Xref | csiph.com comp.lang.java.programmer:23964 |
Show key headers only | View raw
On 5/9/2013 10:53 AM, RVic wrote:
> I inherited someones mountain of code wherein they use different idioms and ways of doing things than I typically do.
>
> In one instance, there is a line of code:
>
> System.getProperty("cn.env");
>
> which, depending on what machine it is run on, has properties like "production" or "mirror"
>
> Yet, I think this call, System.getProperty(), calls properties from the actual system, like (System.getProperty("user.home") or System.getProperty("file.separator").
>
> So how can I set this on a particular machine (Ubuntu 12 in this case) for a value for cn.env?
java -Dcn.env=ZaphodBeeblebrox MyClass
... is one way. See also System.setProperty(), which you could
use in a "launcher" class like
public class Launcher {
public static void main(String[] args) {
// Get a value -- this takes one from the
// environment, but you could get as fancy
// as you like here.
String value = System.getenv("CN_ENV");
// Set the property.
System.setProperty("cn.env", value);
// Run the "real" main() method.
MyClass.main(args);
}
}
--
Eric Sosman
esosman@comcast-dot-net.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Setting a property for System.getProperty() RVic <rvince99@hotmail.com> - 2013-05-09 07:53 -0700
Re: Setting a property for System.getProperty() lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-05-09 16:22 +0100
Re: Setting a property for System.getProperty() Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-05-09 11:33 -0400
Re: Setting a property for System.getProperty() RVic <rvince99@hotmail.com> - 2013-05-09 09:01 -0700
Re: Setting a property for System.getProperty() Arne Vajhøj <arne@vajhoej.dk> - 2013-05-09 21:51 -0400
Re: Setting a property for System.getProperty() RVic <rvince99@hotmail.com> - 2013-05-09 09:14 -0700
Re: Setting a property for System.getProperty() markspace <markspace@nospam.nospam> - 2013-05-09 09:48 -0700
Re: Setting a property for System.getProperty() Arne Vajhøj <arne@vajhoej.dk> - 2013-05-09 21:57 -0400
csiph-web