Statis Class view in java

Hi All,

I just want to clarify myself on 1 concept this is related to a *static class*.

Suppose you have 2 seperate projects deployed on a same Tomcat, where in each project there is a static class with a *same name* . Now my question is would these 2 projects have a shared view of this static class OR each project would have its own view?

Lets assume, In one project, this static class has a variable Name="proj 1", where as the same class in the other project has a variable's value Name = "proj 2".

Now would the value of this variable be different in each project or same?

I hope i have made myself clear.

thanks in advance

[674 byte] By [buttspa] at [2007-11-27 7:10:45]
# 1
both of your projcts are entirely independent of each other, right?Then, I think the static variable of one project will be invisible to the other.Both will have a seperate satic variable.
achyuthba at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 2

> Suppose you have 2 seperate projects deployed on a

> same Tomcat, where in each project there is a static

> class with a *same name* . Now my question is would

> these 2 projects have a shared view of this static

> class OR each project would have its own view?

there is no such thing as a project, but i suppose each web app will have its own context and thus its own class.

CeciNEstPasUnProgrammeura at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 3
there are 2 *different* projects, but each has a SAME STATIC class. So you are saying each project will have its own view?
buttspa at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 4
Ok I have 2 different web application. So you are suggesting that even if we use the same name static class, (which in my case a proprty class) in 2 different web applications, then each woudl have its own view?thanks.
buttspa at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 5
> So you are saying each project will have its own view?Yes. Although I'm not sure what a "view" is supposed to be in this context. Each web app has its own classes, nothing is shared.
CeciNEstPasUnProgrammeura at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 6
> each project there is a static> class with a *same name* .He is saying two seperate static class with same name.
achyuthba at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 7

from view i meant like the following:

String name = propertyClass.getName(); // web application 1

String name = propertyClass.getName(); // web application 2

So in web application 1 the value woudl be = "proj 1"; and in web application 2 the value would be = "proj 2";

Is this assumption here is right?

buttspa at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 8
And a static class with same name would not be a source of confusion for Tomcat/JVM?
buttspa at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 9
How often are we supposed to say "yes"?
CeciNEstPasUnProgrammeura at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 10
> And a static class with same name would not be a> source of confusion for Tomcat/JVM?No. It's normal classloader activity.
CeciNEstPasUnProgrammeura at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 11
:-) thanks Mate. and my apology for bothering you guys more than once.
buttspa at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...
# 12
Actually it depends where the .class file is found. If it's in the WEB-INF/classes or lib directory you'll get two separate Classes loaded. If it's in one of the shared library areas in Tomcat, then the same Class will be shared.
malcolmmca at 2007-7-12 19:02:19 > top of Java-index,Java Essentials,Java Programming...