Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
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??

Inandjo (Programmer) (OP)
3 Feb 06 9:12
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!

sedj (Programmer)
3 Feb 06 10:02
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

Inandjo (Programmer) (OP)
3 Feb 06 10:08
Thanx sedj, but would i still get to retrieve the variable via  System.getProperty("Property_name");??
Thanx

La faim justifie les moyens!

sedj (Programmer)
3 Feb 06 10:29
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

Inandjo (Programmer) (OP)
3 Feb 06 10:31
Thanx mate!!!

La faim justifie les moyens!

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!

Back To Forum

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