strange netbeans glitch not finding java classes

Discussion in 'Java' started by gwlucas@sonalysts.com, Jun 10, 2008.

  1. Guest

    I've just had something strange happen to me in Netbeans 6.1.

    I was editing a file when, all of the sudden, Netbeans became unable
    to find things like java.awt.event.MouseEvent and java.lang.Runnable.
    I have never seen anything like this before. Does anyone have
    experience with that kind of thing? Any suggestions?

    My guess is that somekind of behind-the-scenes updater or something
    ran and broke something (why anyone thinks that behind-the-scenes
    processes that modify your computer environment are a good idea is
    beyond me). I've re-installed Java and am in the process of re-
    installing Netbeans. Anything I should look for?

    Gary
     
    , Jun 10, 2008
    #1
    1. Advertising

  2. Guest

    Okay, I found the source of the problem and it's almost a little
    funny...

    While I was working, I was creating a new class file when somebody
    came in to the office and interrupted. I attmpted to bail out of the
    creation wizard, but being a little distracted, somehow managed to
    create a file called "java.java"

    This turned out to be toxic to Netbeans and the Java compiler. When I
    used Netbeans to edit or compile a file which included a reference to
    one of the Java API classes, such as java.lang.Runtime, it decided
    that I wanted it to find the reference inside the class named
    java.java. While clearly inappropriate, that was the correct behavior
    based on the rules for resolving classpath and reference. So chalk it
    up to operator error.

    This is one of the stranger problems I've seen in a long time.

    I suppose that I would have found it sooner if I had paid more
    attention to the compiler warnings. I just assumed that Netbeans was
    being flakey... Sometimes when you are debugging, it will get into a
    confused state and the only way to correct the problem is to terminate
    and restart the IDE... so having gotten used to the idea that the
    program would misbehave, I wrongly assumed it was misbehaving again.
    The real problem was, of course, that it was doing exactly what it was
    supposed to do.

    Gary



    On Jun 10, 3:07 pm, wrote:
    > I've just had something strange happen to me in Netbeans 6.1.
    >
    > I was editing a file when, all of the sudden, Netbeans became unable
    > to find things like  java.awt.event.MouseEvent and java.lang.Runnable.
    > I have never seen anything like this before. Does anyone have
    > experience with that kind of thing? Any suggestions?
    >
    > My guess is that somekind of behind-the-scenes updater or something
    > ran and broke something (why anyone thinks that behind-the-scenes
    > processes that modify your computer environment are a good idea is
    > beyond me). I've re-installed Java and am in the process of re-
    > installing Netbeans.  Anything I should look for?
    >
    > Gary
     
    , Jun 11, 2008
    #2
    1. Advertising

  3. Roedy Green Guest

    Selecting a "random" quotation

    Here is some code I use to select a "random" quotation to put an a web
    page. It changes every 4 hours.

    /**
    * 86,400,000 the number of milliseconds in 24 hour day. Easily
    fits into an int.
    * We change the quotations every 4 hours, UTC.
    */
    private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
    1000;



    final Adler32 digester = new Adler32();
    int seed = ( int ) ( System.currentTimeMillis() /
    CHANGE_INTERVAL_IN_MILLIS );
    /// digester.update(int) not clearly documented, probably
    wants ubyte.
    digester.update( ( byte ) ( seed & 0xff ) );
    digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
    digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
    digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
    digester.update( fileBeingProcessed.getPath().getBytes(
    "UTF-8" ) );

    // get rid of high sign bit, and low bit, which seem to be
    1 disproportionately.
    final int digest = (( ( int ) digester.getValue() ) << 1)
    >>> 2;

    final String[] candidates = category.getQuotations();

    final String chosenQuote = candidates[ digest %
    candidates.length ];

    However it often SEEMS to sometimes pick the same quote for two
    different pages, more often than I would intutitively think it would.

    Further it SEEMS to favour certain quotes in the collection. I wonder
    if this just my imagination, or there is some flaw in the algorithm.

    --

    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
     
    Roedy Green, Jun 11, 2008
    #3
  4. Re: Selecting a "random" quotation

    In article <>,
    Roedy Green <> wrote:

    > Here is some code I use to select a "random" quotation to put an a web
    > page. It changes every 4 hours.
    >
    > /**
    > * 86,400,000 the number of milliseconds in 24 hour day. Easily
    > fits into an int.
    > * We change the quotations every 4 hours, UTC.
    > */
    > private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
    > 1000;
    >
    >
    >
    > final Adler32 digester = new Adler32();
    > int seed = ( int ) ( System.currentTimeMillis() /
    > CHANGE_INTERVAL_IN_MILLIS );
    > /// digester.update(int) not clearly documented, probably
    > wants ubyte.
    > digester.update( ( byte ) ( seed & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
    > digester.update( fileBeingProcessed.getPath().getBytes(
    > "UTF-8" ) );
    >
    > // get rid of high sign bit, and low bit, which seem to be
    > 1 disproportionately.
    > final int digest = (( ( int ) digester.getValue() ) << 1)
    > >>> 2;

    > final String[] candidates = category.getQuotations();
    >
    > final String chosenQuote = candidates[ digest %
    > candidates.length ];
    >
    > However it often SEEMS to sometimes pick the same quote for two
    > different pages, more often than I would intutitively think it would.
    >
    > Further it SEEMS to favour certain quotes in the collection. I wonder
    > if this just my imagination, or there is some flaw in the algorithm.


    Are you trying to make the sequence of quotes depend on the last
    processed file? Maybe something like this:

    // initially
    Random random = new Random();
    Adler32 digester = new Adler32();
    ...
    // each new file
    digester.update(fileBeingProcessed.getPath().getBytes("UTF-8"));
    ...
    // every n hours
    random.setSeed(digester.getValue());
    chosenQuote = candidates[random.nextInt(candidates.length)];

    John
    --
    John B. Matthews
    trashgod at gmail dot com
    home dot woh dot rr dot com slash jbmatthews
     
    John B. Matthews, Jun 11, 2008
    #4
  5. Tom Anderson Guest

    Re: Selecting a "random" quotation

    On Wed, 11 Jun 2008, Roedy Green wrote:

    > Here is some code I use to select a "random" quotation to put an a web
    > page. It changes every 4 hours.
    >
    > /**
    > * 86,400,000 the number of milliseconds in 24 hour day. Easily
    > fits into an int.
    > * We change the quotations every 4 hours, UTC.
    > */
    > private static final int CHANGE_INTERVAL_IN_MILLIS = 4 * 60 * 60 *
    > 1000;
    >
    > final Adler32 digester = new Adler32();
    > int seed = ( int ) ( System.currentTimeMillis() /
    > CHANGE_INTERVAL_IN_MILLIS );
    > /// digester.update(int) not clearly documented, probably
    > wants ubyte.
    > digester.update( ( byte ) ( seed & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 8 ) & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 16 ) & 0xff ) );
    > digester.update( ( byte ) ( ( seed >>> 24 ) & 0xff ) );
    > digester.update( fileBeingProcessed.getPath().getBytes(
    > "UTF-8" ) );
    >
    > // get rid of high sign bit, and low bit, which seem to be
    > 1 disproportionately.
    > final int digest = (( ( int ) digester.getValue() ) << 1)
    >>>> 2;

    > final String[] candidates = category.getQuotations();
    >
    > final String chosenQuote = candidates[ digest %
    > candidates.length ];


    Why are you doing all this? Why not just new Random(), generate and throw
    away a few ints, and then pick one out and use it?

    > However it often SEEMS to sometimes pick the same quote for two
    > different pages, more often than I would intutitively think it would.
    >
    > Further it SEEMS to favour certain quotes in the collection. I wonder
    > if this just my imagination, or there is some flaw in the algorithm.


    I also have a random quote selector, and i also notice this. There are
    even times when i think it's picking quotes specifically tailored for the
    email i'm about to write. I think it's an illusion - if you randomly pick
    quotes, you don't expect them all to appear at the same frequency, but for
    some to, by chance, come up more often. Isn't it a binomial distribution
    or something? Anyway, it's exactly the kind of thing that the human brain
    interprets as a pattern.

    tom

    --
    Hesgadin. It was in two parts - both of them silent. I remember this map
    came with a letter accusing me of stealing eggs. I had never understood
    the relationship of the map to the accusation. I still don't, but I'm
    grateful for the map.
     
    Tom Anderson, Jun 12, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. zerg
    Replies:
    4
    Views:
    793
  2. Stefan Ram

    Re: CLI Java Glitch

    Stefan Ram, Jun 20, 2011, in forum: Java
    Replies:
    2
    Views:
    302
    Stefan Ram
    Jun 21, 2011
  3. Martin Gregorie

    Re: CLI Java Glitch

    Martin Gregorie, Jun 20, 2011, in forum: Java
    Replies:
    54
    Views:
    1,316
    Andreas Leitgeb
    Jul 25, 2011
  4. Jeff Higgins

    Re: CLI Java Glitch

    Jeff Higgins, Jun 21, 2011, in forum: Java
    Replies:
    9
    Views:
    383
    Tom Anderson
    Jun 21, 2011
  5. Roedy Green

    Re: CLI Java Glitch

    Roedy Green, Jun 21, 2011, in forum: Java
    Replies:
    9
    Views:
    324
    Arne Vajhøj
    Jul 22, 2011
Loading...

Share This Page