The Artima Developer Community
Sponsored Link

Java Answers Forum
modify static variable

4 replies on 1 page. Most recent reply: Apr 17, 2006 7:25 AM by Thomas SMETS

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
abdul jameel

Posts: 2
Nickname: abjameel
Registered: Apr, 2006

modify static variable Posted: Apr 3, 2006 10:25 PM
Reply to this message Reply
Advertisement
Hi,
My java applicaiton is currently running. I want to modiy a static variable of a class contained in that application. I would like to fo this by running another java file, say "java modify.java". I tried to do this but it is not working. Can anyone suggest me a way to do this?

Thanks in advance for any help


Arul Murugan

Posts: 7
Nickname: appaney
Registered: Mar, 2006

Re: modify static variable Posted: Apr 4, 2006 1:45 PM
Reply to this message Reply
Ahmed, I think you cannot modify static variable, this is similar to the final variable. If you need to modify it you have to declare it as instance variable i mean ordinary variable.

If i am wrong pls anybody can correct my answer.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: modify static variable Posted: Apr 6, 2006 2:07 AM
Reply to this message Reply
Of course you can modify static variables. They just don't get destroyed when the instance of the owner get's destroyed.

Static is not like static at all.
The one prevents changing, the other allows to keep a value and to use the same value between different instances.



But I don't know how to communicate between 2 different programs.

In my opinion it should NOT be possible to change variables of another program, that would be a big security issue.

To interact between programs, COM or DCOM are normally used.
Maybe Java has it's own version of it, since standard COM access is not implemented in Java (had to buy a jintegra tool for that).

abdul jameel

Posts: 2
Nickname: abjameel
Registered: Apr, 2006

Re: modify static variable Posted: Apr 7, 2006 2:45 AM
Reply to this message Reply
Hi,
Thanks for your response Arul Murugan & Matthias Neumair. I found a solution for this. As my application is finally deployed in weblogic server, I wrote a jsp to access the static variable and modified it.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: modify static variable Posted: Apr 17, 2006 7:25 AM
Reply to this message Reply
Well they are many options for that ...
You could just have you application pooling a property file and when the file is changed, it will just reload it... This can easily be done with a thread. Based on that approach it could just as weel pool a value in a DB.

Now the more complex approach would be to have a small RPC-server (the java word for it is RMI) to listen and you client application.

You approach (JSP) is dead simple and you should consider this a being the right way to do it... You can also use something slightly more spicy (and a bit of an overkill) for this : JMX / MBeans....

Cheers,

\T,

Flat View: This topic has 4 replies on 1 page
Topic: Running 2 insatnces of Tomcat Previous Topic   Next Topic Topic: client server with time control

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use