String immutability

Hi
I am confused when they say that string is immutable and we need to use StringBuffer instead....
But why the piece of code below is compiling if string be immutable ?
public class Main {
     * @param args the command line arguments
    public static void main(String[] args) {
String  mystring ="Hello how are you ";
mystring ="Are you fine ";
System.out.println(mystring);
}

nogoodatcoding wrote:
Second, Strings are immutable because once created, you cannot modify their content. That's fixed.Except...
import java.lang.reflect.*;
public class ImmutableStringDemo {
    public static void main(String[] args) throws Exception {
        String string = "foo";
        assert "foo".equals(string);
        new StringChanger().change(string);
        assert "bar".equals(string);
class StringChanger {
    public void change(String s) throws IllegalAccessException {
        Field[] fields = s.getClass().getDeclaredFields();
        for (Field f : fields) {
            f.setAccessible(true);
            if (f.getType() == char[].class) {
                f.set(s, "bar".toCharArray());
}Don't try this at home, all standard caveats apply.
~

Similar Messages

  • How can we call String immutable?

    Hello there
    String is immutable, that is, it can not be extended. Then how concat() function works.. or how two strings are appended together with a + sign.
    What is the logic behind?
    Also, what happens when a StringBuffer calls append method, how can a StringBuffer be called mutable?
    Thanks

    String is immutable, that is, it can not be extended.No. String is final so it can't be extended (subclassed). You can't have:    // Won't compile
    class MyString extends String {}Immutable is quite different. It means that once a string is created it will never change its contents.
    Then how concat() function works.concat() works just like the API documentation says it works: It {color:#3333FF}"Concatenates the specified string to the end of this string.
    If the length of the argument string is 0, then this String object is returned. Otherwise, a new String object is created, representing a character sequence that is the concatenation of the character sequence represented by this String object and the character sequence represented by the argument string"{color}.
    http://java.sun.com/javase/6/docs/api/java/lang/String.html#concat(java.lang.String)
    Notice the bit that says {color:#3333FF}a new String object is created{color} - that's because Strings are immutable. Neither of the strings you start with are (or can be) changed. Instead a new String is created.
    Also, what happens when a StringBuffer calls append methodYou can read for yourself here: http://java.sun.com/javase/6/docs/api/java/lang/StringBuffer.html#append(java.lang.String) The important thing is that no new StringBuffer is created. The string being appended is ... appended and the string buffer's contents are changed (it's now longer).
    how can a StringBuffer be called mutable?Since the contents of a StringBuffer can change - for instance if append() is invoked with a non-empty String argument.
    For other classes the contents might be called state.
    StringBuffer, by the way, is final like String. But it's not immutable.

  • How are strings immutable in java

    for e.g.
    String x="abc";
    x+="DEF";
    x=x.toLowerCase()
    System.out.println("String is "+x);
    if u run the above code it prints -String is abcdef
    If strings are immutable hows it possible

    Try the following:
    public class test
         public static final void main(String args[])
              final int MAXCOUNTER = 10000;
              String s = new String();
              long t1 = System.currentTimeMillis();
              for(int i = 0;i < MAXCOUNTER;i++)
                   s += ".";
              t1 = System.currentTimeMillis() - t1;
              StringBuffer sb = new StringBuffer();
              long t2 = System.currentTimeMillis();
              for(int i = 0;i < MAXCOUNTER;i++)
                   sb.append(".");
              t2 = System.currentTimeMillis() - t2;
              System.out.println("String: " + s);
              System.out.println("StringBuffer: " + sb.toString());
              System.out.println("Time elapsed creating a String containing " + MAXCOUNTER + " dots: " + t1 + "ms");
              System.out.println("Time elapsed creating a String containing " + MAXCOUNTER + " dots: " + t2 + "ms");
    }You'll notice that the time elapsed when creating the string using the StringBuffer.append() method is a lot smaller than the time spent creating the string using the + String operator.
    Why? Because each time the + operator is called, it returns a new String object. It can't modify the String object in which it is used. The same happens with other String operations. The StringBuffer.append() method actually really appends the dot to the end of the buffer, it doesn't create a new StringBuffer for that.
    I think the constants pool is only used for the constants hard coded into the source code (the ones you write between double quotes inside the source code).
    That's why it's preferred to use StringBuffers when you do many String operations.

  • Is there a method for adding a character to a string?

    Hello,
    is there a String method to add a Char to a String given the character number on the string?
    EXAMPLE:
    String text = "hello world"
    I'd like to add a comma after the the 'o' (4th character) so I that text reads: "hello, world"
    is there something like:
    text.addChar(Char, position in string) ?

    avanrotciv wrote:
    Looce wrote:
    Strings are not modifiable. However, if you make a StringBuffer out of it, you can use its insert(index, String) or insert(index, char) method.This is what I was looking for Thanks.
    Should Strings just be directly modifiables? what's the reason they are not?The terms that are usually used are mutable (aka modifiable) and immutable (not modifiable).
    [_Why are Strings immutable?_|http://forums.sun.com/thread.jspa?threadID=5332008]

  • Stringbuilder  replacement of string ?

    can we say stringbuilder is replacement of string class. Because stringbuilder provides all features of string with mutability advatange. i mean whereever we used string in past we can simply use stringbuilder in plase of that ?

    JavaFunda wrote:
    Yes i agree its a programming error if we dont declare source variables as synchronized . But i am trying to understand if we dont declare source variables(say one is string and another is strinbuilder) as synchronized, how come string immutability provides the advantage over string builder mutability in? Thats the only intention of question. sorry for inconvenience.First, you can't declare variables as synchronized; you can only declare them as 'volatile', which is slightly different.
    The advantage of an immutable object, be it String or any other type, is that you know it can't change. That means that you can hand it around in a multi-threaded environment secure in the knowledge that Thread B will see the same value as Thread A. If you hand around a StringBuilder, you have no such guarantee because any third party that has access to the same object can change it.
    There is also a category of objects called "Thread-safe", but it's too big a topic to go into here. I suggest you read up on the subject in the tutorials or via Google. I'll just say this: immutable objects are Thread-safe by definition.
    Other than the exception I listed above, the only real advantage of a StringBuilder is that you can sometimes build String-like values faster and more concisely with it than you can with String (and in most cases we're talking nanoseconds of difference). If you're dealing with very large iterations, it may make a difference (particularly in space), and it's also more likely that code that uses StringBuilder will run in more constant time; but you still have the overhead of having to convert back to Strings at some point, because far more methods take Strings than StringBuilders.
    Winston

  • Immutable String in a swing.text.Document

    Hello,
    I want to add to a text component an 'immutable' bit of text. That is a string that is one 'item', it can not be broken or split. If for example if you wanted to delete you would have to delete the whole thing, not part of it.
    Does anyone know how to do this?
    I'm currently using a JTextPane and struggling with the Document interface.
    Some context to this. I'm building a widget like the Outlook 'to field'. You type text in and it looks up that text in a list of contacts. You can select from the list. When you do this the contact is added to the text box and is underlined and made bold and becomes 'immutable' in the way that I have explained above.
    In an ideal World I would want to do this :
    be able to add a ContactElement to the text pane. Be able to specifiy that ContactElements are to be rendered in bold and underlined and would display the name attribute of the Contact object. These ContactElements would be 'immutable' as described above. Get a list of the ContactElements in the text pane and thus the contacts displayed.
    hope that makes sense, all help gratefully received,
    thanks, Tom

    When you insert a ContactElement, create two Position objects representing the start and end points of the element, and save them. Whenever the user moves the caret, refer to your list of ContactElement end points to see whether the new location is inside one. If it is, either whisk the caret to the other end or select the whole thing, whatever seems appropriate. I've never used it, but I believe NavigationFilter is the tool for that job.
    Any time text is deleted, you'll need to check the list to see if the deleted section contained any ContactElements, and to remove them from the list if so. I was going to recommend using a DocumentListener for that, but I don't think it would work; all the Positions would already have been updated. I suggest using a DocumentFilter to update the list before deleting the text.
    One complication that occurs to me is searching, or other operations that involve programmatic selection or highlighting. The NavigationFilter is too low-level; you'll have to make sure the search feature doesn't look inside ContactElements. You'll probably find other higher-level tasks that need to be aware of ContactElements so they can treat them specially.

  • Strings are immutable

    I want to know what exactly it means when u say that Strings r immutable.I need to understand with ex.please.There r StringBuffers to handle it we say.
    We can concatenate a string with another too. SO what is immutable means?
    CAn anyone help?Thanks in advance.

    Immutable means that the object can not be modified after it is constructed. For Strings, there are no methods that allow the value of the String to be changed. Thus, for a every new value, a new String object must be created. StringBuffers on the other hand, have methods like append and setCharAt that allows the value stored to be changed. You can create one StringBuffer object and keep altering it.
    Concatenation does not actually modify a String. It creates a new one. Notice how you have to assign the concatenated value to something.
    String str1;
    str1 = "test ";
    str1 + "string";
    System.out.println(str1);  // concatenation didn't modify str1
    str1 = str1 + "string";  // assign a new string which is the concatenation of str1 and "string" to str1
    System.out.println(str1);  // str1 refers to a completely new String, the concatenation
    StringBuffer sb1;
    sb1 = new StringBuffer("test ");
    sb1.append("string");
    System.out.println(sb1);  // sb1 was modified
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Why String Objects are immutable ?

    From the JLS->
    A String object is immutable, that is, its contents never change, while an array of char has mutable elements. The method toCharArray in class String returns an array of characters containing the same character sequence as a String. The class StringBuffer implements useful methods on mutable arrays of characters.
    Why are String objects immutable ?

    I find these answers quite satisfying ...
    Here's a concrete example: part of that safety is ensuring that an Applet can contact the server it was downloaded from (to download images, data files, etc) and not other machines (so that once you've downloaded it to your browser behind a firewall, it can't connect to your company's internal database server and suck out all your financial records.) Imagine that Strings are mutable. A rogue applet might ask for a connection to "evilserver.com", passing that server name in a String object. The JVM could check that this server name was OK, and get ready to connect to it. The applet, in another thread, could now change the contents of that String object to "databaseserver.yourcompany.com" at just the right moment; the JVM would then return a connection to the database!
    You can think of hundreds of scenarios just like that if Strings are mutable; if they're immutable, all the problems go away. Immutable Strings also result in a substantial performance improvement (no copying Strings, ever!) and memory savings (can reuse them whenever you want.)
    So immutable Strings are a good thing.
    The main reason why String made immutable was security. Look at this example: We have a file open method with login check. We pass a String to this method to process authentication which is necessary before the call will be passed to OS. If String was mutable it was possible somehow to modify its content after the authentication check before OS gets request from program then it is possible to request any file. So if you have a right to open text file in user directory but then on the fly when somehow you manage to change the file name you can request to open "passwd" file or any other. Then a file can be modified and it will be possible to login directly to OS.
    JVM internally maintains the "String Pool". To achive the memory efficiency, JVM will refer the String object from pool. It will not create the new String objects. So, whenever you create a new string literal, JVM will check in the pool whether it already exists or not. If already present in the pool, just give the reference to the same object or create the new object in the pool. There will be many references point to the same String objects, if someone changes the value, it will affect all the references. So, sun decided to make it immutable.

  • Why String class is defined as immutable?

    Why String class is defined as immutable? what can be the reason behind it?

    Do try this at home. :)
    public class Main {
        public static void main(String... args) {
            System.out.println("Greetings.");
            System.out.println("Goodbye.");
        static {
            // translates into Japanese. NOT a good idea!
            try {
                final Field field = String.class.getDeclaredField("value");
                field.setAccessible(true);
                char[] chars = new char[8];
                "Sayonara".getChars(0,8,chars,0);
                field.set("Goodbye.", chars);
                chars = new char[10];
                "Konichi-wa".getChars(0,10,chars,0);
                field.set("Greetings.", chars);
            } catch (Exception e) {
                throw new AssertionError(e);
    }

  • Immutable Strings

    I understand that a new String class is created every time you modify a String.
    Does that even include changing it to lower case or upper case
    ArrayList.add(stringvariable.toLowerCase());
    stev

    okay what happens when you do an equalsIgnoreCase
    for example this creates a new classNot a new class, a new "instance" of that class, commonly called an Object.
    stringVariable = avariable.toLowerCase();if avariable is not all lower case this creates a new String object of the lower case version of avariable and returns it, other wise it returns avariable.
    if(stringVariable.equals("joe"){}
    what happens here?stringVariable is compare lexigraphically to "joe". Joe is actually created as a new String and placed in the "interning" String pool of the VM.
    >
    if(stringVariable.toLowerCase.equals("joe"){}
    and which is most efficient in say 1mil iterationscorrection:
    if(stringVariable.toLowerCase().equals("joe"){}
    This statement could result in the creation of Two new Strings.
    Because TONS of String objects can be created in a program that processes lots of strings. Cough.. A Compiler.... Java provides an internal String pool to store String references. Used properly you will never have to call .equals() on two strings again. The literal string "joe" is automatically placed inside the String pool. So it's reference is always equals to another interned string equals to "joe". like so..
    new String("joe") == "joe" <-- might not be true
    new String("joe").intern() == "joe" <-- always true
    Using this internal String pool can give a huge speed increase on string intensive programs.

  • About Strings and Memory

    Let's look at a couple of examples of how a String might be created, and let's further assume that no other String objects exist in the "String constant pool"l:
    String s = "abc"; //   creates one String object and one
                      //   reference variable In this simple case, "abc" will go in the pool and s will refer to it.
       String s = new String("abc"); // creates two objects,
                                  // and one reference variable In this case, because we used the new keyword, Java will create a new String object
    in normal (nonpool) memory, and s will refer to it. In addition, the literal "abc" will
    be placed in the pool.
    My question is this:
    Then why did the sun developers created the 'public String(String str)' constructor even it uses an additional memory?

    Caarmel wrote:
    Let's look at a couple of examples of how a String might be created, and let's further assume that no other String objects exist in the "String constant pool"l:
    String s = "abc"; //   creates one String object and one
    //   reference variable In this simple case, "abc" will go in the pool and s will refer to it.Nope. Executing that line only assigns a reference to an already existing String into the variable. The constant was put into the pool when the class was loaded. So your initial assumption of no Strings in the constant pool is invalid.
       String s = new String("abc"); // creates two objects,
    // and one reference variable Nope. As above, it creates one object. The other already existed.
    Then why did the sun developers created the 'public String(String str)' constructor even it uses an additional memory?First, note that your question really has nothing at all to do with the constant pool. Your question is really "Why does the String(String) constructor exist, given that String is immutable, and given that we can just do s2 = s1?" That question applies even in complete absence of the constant pool.
    I wasn't there when they made the decision, so I can't tell you what their thinking was. I can tell you one case where it's useful, however.
    String s1 = some_very_long_string;
    String s2 = s1.substring(x, x + a_small_number);
    String s3 = new String(s1.substring(x, x + a_small_number);Both the s2 and s3 lines create new String objects. However, in the case of s2, the new object shares the same char array as the original, whereas in the s3 case, a new backing array of just the right size is created. If s1 is very large, AND if the substring we're extracting is very small, AND if the substring needs to live on significantly longer than the original, then without the explicit new String(), even though we only need a few characters and could get away with a very small char array, we end up stuck with a large char array that can't be GCed even when the original String is.
    So in this rather unlikely scenario, we can avoid wasting a bunch of memory that can't be GCed when we only need a small fraction of it.
    Or maybe the constructor came about in early versions, before other aspects of the language making it mostly useless were solidified, and then it was kept for backward compatibility.
    Or maybe they didn't really have a good reason and just figured it made sense to have a copy constructor.
    Or maybe the reasons that make it mostly redundant are implementation details, and they wanted to provide a copy constructor so that as Java evolved, if the implementation changed, the functionality would still be there.
    Or maybe none of the above.

  • Matrix-like PKs based on three optional IN-constrained strings?

    Hello,
    I have a DB of actions that I want to represent. I want to model a number of actions as you know them from classic GUIs:
    open
    openFile
    saveAs
    exportToDirectory
    reverseEngineerFromDatabase
    As I analyzed the problem, I came to the conclusion, the keys above (which they ultimately are) have at least three parts:
    1. an action: VARCHAR(20) CHECK (action IN ('open', 'save', 'export', 'reverseEngineer', ...))
    2. a preposition: VARCHAR(4) CHECK (preposition IN ('as', 'to', 'from', ...))
    3. a target: VARCHAR(20) CHECK (target IN ('file', 'directory', 'database', ...))
    So the rule to construct the final key would be:
    <action> + <preposition> + <target>
    to model all sorts of combinations/permutations (forget about uppercasing the preposition and target if there for a moment).
    As you can see from the strings, I have three dimensions of predefined values from which I construct the final key. Not every combination is possible, I want to represent valid combinations by an extra table having entries like:
    INSERT INTO ValidActions ('open', '', '')
    INSERT INTO ValidActions ('open', '', 'file')
    INSERT INTO ValidActions ('save', 'as')
    INSERT INTO ValidActions ('export', 'to', 'directory')
    INSERT INTO ValidActions ('reverseEngineer', 'from', 'database')
    My question is now:
    How do I solve this, given that the PK is composed of ... PRIMARY KEY (action, preposition, target) ... and that an action has an OPTIONAL preposition and target? I have not come to a final decision, but I might relax the action to be optional, too, and then demand that either <action> OR <target> MUST be set.
    How do I model matrix-like composed PKs consisting of a number of optionals? I currently see no other way of adding empty strings '' to the check constraint, however AFAIK Oracle does not make a difference between NULL and the empty string ''. How would such a solution look like?
    I could use the final string as PK, but how do I make sure that string consists of the predefined ones only?
    Karsten
    PS: note action and target are actually two separate tables.

    What about using a model like this? I used surrogate keys because I wasn't sure if the ACTION, PREPOSITION and TARGET values were truly immutable. You could easily remove these from the model and use the respective columns as the PK for each table.
    DROP TABLE ACT_PRE_TAR;
    DROP TABLE ACTIONS;
    CREATE TABLE ACTIONS
            ACTION_ID       NUMBER  PRIMARY KEY
    ,       ACTION          VARCHAR2(15) NOT NULL
    ,       CONSTRAINT ACTION#UNQ UNIQUE (ACTION)
    INSERT INTO ACTIONS VALUES(1,'open');
    INSERT INTO ACTIONS VALUES(2,'save');
    INSERT INTO ACTIONS VALUES(3,'export');
    INSERT INTO ACTIONS VALUES(4,'reverseEngineer');
    DROP TABLE PREPOSITIONS;
    CREATE TABLE PREPOSITIONS
            PREPOSITION_ID  NUMBER  PRIMARY KEY
    ,       PREPOSITION     VARCHAR2(10) NOT NULL
    ,       CONSTRAINT PREPOSITION#UNQ UNIQUE (PREPOSITION)
    INSERT INTO PREPOSITIONS VALUES (1,'as');
    INSERT INTO PREPOSITIONS VALUES (2,'to');
    INSERT INTO PREPOSITIONS VALUES (3,'from');
    DROP TABLE TARGETS;
    CREATE TABLE TARGETS
            TARGET_ID       NUMBER  PRIMARY KEY
    ,       TARGET          VARCHAR2(10) NOT NULL
    ,       CONSTRAINT TARGETS#UNQ UNIQUE (TARGET)
    INSERT INTO TARGETS VALUES (1,'file');
    INSERT INTO TARGETS VALUES (2,'directory');
    INSERT INTO TARGETS VALUES (3,'database');
    CREATE TABLE ACT_PRE_TAR
            ACTION_ID       NUMBER  REFERENCES ACTIONS(ACTION_ID)
    ,       PREPOSITION_ID  NUMBER  REFERENCES PREPOSITIONS(PREPOSITION_ID)
    ,       TARGET_ID       NUMBER  REFERENCES TARGETS(TARGET_ID)
    ,       CONSTRAINT ACT_PRE_TAR#UNQ UNIQUE (ACTION_ID, PREPOSITION_ID, TARGET_ID)
    );Based on your sample data the following result is produced:
    SQL> SELECT  ACTION
      2  ,       PREPOSITION
      3  ,       TARGET
      4  FROM            ACT_PRE_TAR
      5  LEFT OUTER JOIN ACTIONS         ON ACTIONS.ACTION_ID            = ACT_PRE_TAR.ACTION_ID
      6  LEFT OUTER JOIN PREPOSITIONS    ON PREPOSITIONS.PREPOSITION_ID  = ACT_PRE_TAR.PREPOSITION_ID
      7  LEFT OUTER JOIN TARGETS         ON TARGETS.TARGET_ID            = ACT_PRE_TAR.TARGET_ID
      8  /
    ACTION          PREPOSITIO TARGET
    open
    open                       file
    save            as
    export          to         directory
    reverseEngineer from       database

  • Difference in String joining

    String m="Hello"
    Is there any difference between
    m=m+" Java";
    and
    m=m.concat(" Java");There must be some difference I guess, but not sure where.
    Can anyone explain please?

    Another interview question?
    Adding strings with + gets compiled into instantiations and invocations of StringBuffer or StringBuilder, invoking append() on it, and then calling toString on it. That is, unless the stuff you're adding is all immutable at compile time, in which case the concatenation happens at compile time and the class just has a big string.
    .concat(), I presume, creates a new String object right there and doesn't get transmogrified into anything else at compile time.
    As such, if you're doing a lot of string concatenations, or if the concatenations are built with immutable values, it's more efficient to use +. On the other hand if you're doing a single concatenation using a variable, .concat() is probably more efficient.
    But these are just educated guesses. Try experimenting with both, disassembling the class files with javap to see what happened, looking at the source code, etc.

  • Query on Strings in point of memory..?

    Can any one explain the below code clearly in point of memory?
    String A = new String("abc"); // 1. How many objects are created here?
    String B = "def"; //2. How many objects here?
    A = A + B; // Here Value of A is 'abcdef'.
    As we know String objects are immutable. The value of A is visible here 'abcdef' why cannt only 'abc'. Here reference of A was changed but how can we prove here the value of A is same at any time..? Plz explain clearly.

    String A = new String("abc"); // 1. How manyobjects
    are created here?One.
    I heard that in above statement two objects are
    created. this is one in String Constant Pool and
    anothe is in Heap memory. Is it right?
    If not wht is the use of String Constant Pool? If it
    is right why String Objects are create in Heap as
    well as String Constant Pool?I think it's correct that "abc" is placed in contant pool, and that new String creates yet another object.
    You can verify that a string is immutable by executing the following code.
    String a = "abc";
    String tmp = a;
    String a = a.concat("def");
    System.out.println(a);
    System.out.println(tmp);Kaj

  • Pls help me with Strings.................

    Hi,
    i'm need to get the html content from the site. So i create this getURLContent
    method. However, the method keep return null to main() which call this method.
    Someone pls help me with it.......
    Thanks in advance!
    Here's my method created.
    public String getURLContent(String site){
         String urlContent = "";
         try {
              URL url = new URL(site);
              HttpURLConnection con = (HttpURLConnection)
    url.openConnection();
              con.setRequestMethod("GET");
              con.connect();
              int code= con.getResponseCode();
              if (code == HttpURLConnection.HTTP_OK) {
                   BufferedReader r= new BufferedReader(new
    InputStreamReader(con.getInputStream()));
                   String s = "";
              while ((s = r.readLine()) != null)
                   urlContent.concat(s);
         catch (Exception e) { e.printStackTrace(); }
         return urlContent;
    }

    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    Strings are immutable.
    Strings, String Buffers, and String Builders
    Create a StringBuffer, use .append, then return stringBuffer.toString().

Maybe you are looking for

  • Authorization to view Queries

    Hi, my colleague just executed a query and got a whole set of values in his report result. when I executed the same query with my login details, i got a blank screen with no result. Is this an Authorisation problem? How do I get all the authorisation

  • How can I change dates on photos in Elements so I can control order of photos in album in adoberevel

    I have some of my photos in adoberevel albums, and have learned the only way to change the order of those photos in those albums is to change the date or event in my Elements 9 library. I'd prefer to work with changing the photo date, but don't know

  • Handles disappear

    Sometimes, when working on an Illustrator document the handles of (all) objects disappear. Neither clicking with the select- nor the direct selection tool will show handles. Rebooting doesn't solve the problem. It seems to be some kind of setting tha

  • I can't find my camera icon so i can't take pictures

    I have a 3gs and the camera icon has disapeared

  • Getting (err = -3259)

    I've been getting (err = -3259) when trying to download some podcasts. The odd thing is that they download slowly for a few minutes then it gives me the error. Also I've tried shutting down my anti-virus and the windows firewall but it doesn't help.