Smart questions
Smart answers
Smart people
Join Tek-Tips Forums

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.

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

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:
String var = System.getProperty("VARIABLEG");
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:
 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

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

La faim justifie les moyens!

sedj (Programmer)
3 Feb 06 10:29
No, you would use another method. For example, in web.xml :





and in a servlet or JSP :


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

Free Java/J2EE Database Connection Pooling Software

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