Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6038473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:13:36+00:00 2026-05-23T06:13:36+00:00

Are Java static variables shared across instances of the same web application? class MyClass

  • 0

Are Java static variables shared across instances of the same web application?

class MyClass
{
    private static SomeClass myStaticObject = new SomeClass();
}

If a web application uses MyClass and multiple instances of that application is run on a web server, is myStaticObject initialized multiple times?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:13:37+00:00Added an answer on May 23, 2026 at 6:13 am

    Typically, yes. Most containers will provide separate classloaders for each web application. This will result in the class being loaded multiple times when used by several applications, and thus resulting in multiple instances of the static variable.

    Stating the Java Language Specification for reference:

    At run time, several reference types
    with the same binary name may be
    loaded simultaneously by different
    class loaders. These types may or may
    not represent the same type
    declaration. Even if two such types do
    represent the same type declaration,
    they are considered distinct.

    By inference, multiple instances of static variables will exist, unless the classes are loaded only once by a parent class loader, and never loaded elsewhere by any other class loader.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Unsure about static variables. import java.io.File; public class Logger { public static final File
I am trying to access STATIC Variables from one java class to another but
class MyClass { private static MyClass obj; public static MyClass getInstance() { if(obj==null) {
In java,There is only one instance of static variables, and the values are shared
I heard that static methods should use only static variables in java. But, main
Based on my understanding of the Java language, static variables can be initialized in
Why are interface variables static and final by default in Java?
In Java, static final variables are constants and the convention is that they should
I want to initialize a static Class variable in Java: public class NumberExpression {
I have a Java class in which every method was defined as static .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.