This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes Updating Java attribute in an running Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Updating Java attribute in an running Application" Watch "Updating Java attribute in an running Application" New topic
Author

Updating Java attribute in an running Application

Gagan Tiwari
Ranch Hand

Joined: Jun 10, 2008
Posts: 68
Hi All,

I have a running application. I need to change an attribute of a Java Source without bringing down the application.

Is there any way in Java to acheive this?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18167
    
    8

You can't expect that changing the source code would affect the application from which it was compiled. And besides, source code doesn't have "attributes", does it?

So let's suppose you didn't mean that. You actually want to change the value of some variable in the code which is running. To which the answer is, sure, you can do that if you have designed the code in the right way.

For example the code might periodically read a file and change the value of that variable depending on what it finds there. Or it might run a server which waits for requests, and change the value of that variable depending on what is in the request. I'm sure there are plenty of other ways.
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2247

Paul Clapham wrote:For example the code might periodically read a file and change the value of that variable depending on what it finds there. Or it might run a server which waits for requests, and change the value of that variable depending on what is in the request. I'm sure there are plenty of other ways.


Agreed.

Gagan, what exactly do you mean by "I need to change an attribute of a Java Source without bringing down the application"? Something like, you need to change the type of an instance variable from String to Integer? Hopefully, you'll be able to solve your problem with the explanation Paul provided above.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating Java attribute in an running Application
 
Similar Threads
How are ServletContext attributes GC'd
How to know which are the application are running presently
Eclipse -D Debug vs Run
Mysql JBOSS Connectivity
using ClassPathXmlApplicationContext to load beans