INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

How to set custom environment variables at startup??

How to set custom environment variables at startup??

How to set custom environment variables at startup??

(OP)
Hi,

I am using tomcat 5.0 on a win2K box, and i cant seem to get an environment variable of mine to be set at startup.
The idea is that I would have a variable called VARIABLEG, that i could setup at tomcat startup, and then retrieve this variable later in a java program, the following way:
<code>
String var = System.getProperty("VARIABLEG");
System.out.println(var);
</code>
I tried by creating that variable in the startup.bat, by putting the following line, but it didn't work(I got a null value!!):
<code>set VARIABLEG=something</code>
I also googled it and found a way to do it by using the configure program under "apache software foundation" in the windows start/program files menu.
I added a line in the java options:
-DVARIABLEG=something
 but that didn't work either.
I'm running out of options, and can't understand why such a simple thing is such a headach to get working!
Is there something I'm doing wrong, or am I just being plain dumb and stupid???

La faim justifie les moyens!

RE: How to set custom environment variables at startup??

I would really advise against setting application level variables via the JVM.

If your application needs a variable, then you should add it the the webapp's web.xml really.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
http://www.primrose.org.uk

RE: How to set custom environment variables at startup??

(OP)
Thanx sedj, but would i still get to retrieve the variable via  System.getProperty("Property_name");??
Thanx

La faim justifie les moyens!

RE: How to set custom environment variables at startup??

No, you would use another method. For example, in web.xml :

CODE

<web-app>

  <context-param>
    <param-name>name</param-name>
    <param-value>value</param-value>
  </context-param>

</web-app>



and in a servlet or JSP :

CODE

String value = getServletContext().getInitParameter("name");

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
http://www.primrose.org.uk

RE: How to set custom environment variables at startup??

(OP)
Thanx mate!!!

La faim justifie les moyens!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close